! function () {
    "use strict";

    function e(e, t) {
        var i = function () {};
        i.prototype = t.prototype, e.prototype = new i, e.prototype.constructor = e, e.base = t.prototype
    }

    function t(e, t, i) {
        var a = e ? "required" : "";
        if (t) switch (t) {
            case "date":
                a += " pattern='^\\d{4}-\\d{2}-\\d{2}$'";
                break;
            case "integer":
                a += " pattern='^(\\-|\\+)?\\d+$'";
                break;
            case "float":
                a += " pattern='^(\\-|\\+)?\\d+(\\.\\d+)?$'";
                break;
            case "text":
                "mobile" === i ? a += " pattern='^1\\d{10}$'" : i && (a += " pattern='" + i + "'")
        }
        return a
    }

    function i(e) {
        return e.optionsConfig && g_form.config && $.isArray(g_form.config[e.optionsConfig]) ? g_form.config[e.optionsConfig] : $.isArray(e.options) ? e.options : []
    }

    function a(e, t) {
        $.each(e, function (e, i) {
            var a = "&diseaseId=" + t + "&formResultId=" + i.resultId,
                n = i.picId,
                s = i.picId.split(".").pop();
            n = n.substring(0, n.indexOf(s) - 1), i.url = "/api/Attachment?id=" + n + "_t." + s + a, i.fullUrl = "/api/Attachment?id=" + n + "." + s + a
        })
    }

    function n(e, t) {
        if (!e.sub) return null;
        var i = null;
        return $.each(e.sub, function (e, a) {
            a.key === t && (i = a)
        }), i
    }

    function s(e, t, i) {
        for (0 == e.scrollTop && (e.scrollTop = 1); 0 == e.scrollTop && e.rows > t;)
            if (e.rows--, e.scrollTop = 1, e.rows < i && (e.style.overflowY = "hidden"), e.scrollTop > 0) {
                e.rows++;
                break
            } for (; e.scrollTop > 0;) {
            if (!(e.rows < i)) {
                e.style.overflowY = "auto";
                break
            }
            e.rows++, 0 == e.scrollTop && (e.scrollTop = 1)
        }
    }
    window.mediForm = window.mediForm || {}, window.mediForm.util = {
        extend: e,
        getTextValidateTag: t,
        getEffectiveOptions: i,
        initImgsUrl: a,
        findKeyInSub: n,
        autoSizeTextarea: s
    }
}(),
function () {
    "use strict";

    function e(e) {
        t(e), i();
        var l = s();
        o = l.saveLogic, n(l.internal), a(l.external)
    }

    function t(e) {
        $.each(mediForm.logicRule, function (t, i) {
            "function" == typeof i.clearStatus && i.clearStatus(e)
        })
    }

    function i() {
        g_form.reference && g_form.referenceFields && $.each(g_form.referenceFields, function (e, t) {
            "undefined" == typeof g_form.reference[t.key] || !t.writeTo || !mediForm.fldCtrls[t.writeTo] || "always" !== t.writeMode && g_form.result || mediForm.fldCtrls[t.writeTo].setValue(g_form.reference[t.key])
        })
    }

    function a(e) {
        var t = {},
            i = [],
            a = null;
        $.each(e, function (e, i) {
            var a, n = mediForm.fldCtrls[e];
            if (!n) return !0;
            switch (n.fieldInstance.ctrl) {
                case "CheckBox":
                    a = "key";
                    break;
                case "CheckBoxList":
                    a = "result";
                    break;
                default:
                    a = "value"
            }
            i.forEach(function (e) {
                if (e.logic.refreshOnOpen !== !1) {
                    var i = mediForm.logicRule[e.logic.type],
                        a = i.execute(e.mainField, e.logic, !0);
                    a && a.error && !t[e.mainField.key] && (t[e.mainField.key] = a)
                }
            }), n.koValue()[a].subscribe(function () {
                i.forEach(function (e) {
                    var t = mediForm.logicRule[e.logic.type];
                    t.execute(e.mainField, e.logic, !1)
                })
            })
        }), $.each(t, function (e, t) {
            i.push(t.error), !a && t.fieldKey && (a = t.fieldKey)
        }), i.length > 0 && (i.unshift("表单中有如下数据填写错误："), alert(i.join("\r\n")), a && mediForm.fldCtrls[a].focusError())
    }

    function n(e) {
        $.each(e, function (e, t) {
            var i = t.mainField;
            $.each(t.types, function (e, t) {
                var a = mediForm.logicRule[e];
                a.initLogic(i, t)
            })
        })
    }

    function s() {
        var e = {},
            t = {},
            i = {};
        return $.each(mediForm.fldCtrls, function (a, n) {
            var s = n.fieldInstance;
            return s.logic ? void s.logic.forEach(function (n) {
                var l = n.type,
                    o = mediForm.logicRule[l];
                o && ("function" == typeof o.needSaveLogic && o.needSaveLogic(n) && (i[a] || (i[a] = {
                    mainField: s,
                    logics: []
                }), i[a].logics.push(n)), o.inCtrlLogic ? (t[a] || (t[a] = {
                    mainField: s,
                    types: {}
                }), t[a].types[l] || (t[a].types[l] = []), t[a].types[l].push(n)) : o.getSubscribeFields(s, n).forEach(function (t) {
                    e[t] || (e[t] = []), e[t].push({
                        mainField: s,
                        logic: n
                    })
                }))
            }) : !0
        }), {
            external: e,
            internal: t,
            saveLogic: i
        }
    }

    function l(e) {
        if (!o) return null;
        var t = [],
            i = null;
        return $.each(o, function (e, a) {
            a.logics.forEach(function (e) {
                var n = mediForm.logicRule[e.type],
                    s = n.getError(a.mainField, e);
                s && s.error && (t.push(s.error), !i && s.fieldKey && (i = s.fieldKey))
            })
        }), t.length > 0 ? (t.unshift("表单中有如下数据填写错误："), {
            error: t.join("\r\n"),
            fieldKey: i
        }) : null
    }
    var o = null;
    window.mediForm = window.mediForm || {}, window.mediForm.commonLogic = {
        init: e,
        save: l
    }
}(),
function () {
    "use strict";
    window.mediForm = window.mediForm || {}, mediForm.ctrls = mediForm.ctrls || {}, mediForm.layout = {
        colCount: 4,
        width: 0,
        leftRowSpan: 0,
        rowColSpan: 0,
        rowSpanFirstLine: !1
    }, mediForm.ctrls.BaseCtrl = function () {
        this.fieldInstance = null, this.isSimpleValue = !1, this.koValue = null, this.$container = null, this.isHidden = !1, this.hasNoValue = !1
    }, mediForm.ctrls.BaseCtrl.prototype.render = function (e, t, i) {
        this.fieldInstance = t, this.isSimpleValue = "object" !== t.data.type && "arrayOfValue" !== t.data.type && "arrayOfObject" !== t.data.type, this.koValue = ko.mapping.fromJS(this.getDefaultValue());
        var a;
        if ("hide" !== this.fieldInstance.mode) {
            var n = "",
                s = "";
            if (this.fieldInstance.layout.height && (n = "rowspan='" + this.fieldInstance.layout.height + "'", mediForm.layout.leftRowSpan = this.fieldInstance.layout.height, mediForm.layout.rowColSpan = this.fieldInstance.layout.width, mediForm.layout.rowSpanFirstLine = !0), this.fieldInstance.cssClass && (s = " " + this.fieldInstance.cssClass), this.fieldInstance.layout.newRow || mediForm.layout.width % mediForm.layout.colCount + this.fieldInstance.layout.width > mediForm.layout.colCount) {
                var l = mediForm.layout.colCount - mediForm.layout.width % mediForm.layout.colCount,
                    o = e.children("tr:last");
                l !== mediForm.layout.colCount && ($("<td colspan='" + l + "' class='field-cell-" + l + "'></td>").appendTo(o), mediForm.layout.width += l)
            }
            var d = mediForm.layout.width % mediForm.layout.colCount === 0,
                o = d ? $("<tr></tr>").appendTo(e) : e.children("tr:last"),
                r = $("<td colspan='" + this.fieldInstance.layout.width + "' " + n + " class='field-cell-" + this.fieldInstance.layout.width + s + "'></td>").appendTo(o);
            mediForm.layout.width += this.fieldInstance.layout.width, d && mediForm.layout.leftRowSpan >= 1 && (mediForm.layout.leftRowSpan--, mediForm.layout.rowSpanFirstLine ? mediForm.layout.rowSpanFirstLine = !1 : mediForm.layout.width += mediForm.layout.rowColSpan), i && r.addClass("readonly"), a = r
        } else a = $("#hideContainer");
        var u = "field form-group";
        this.fieldInstance.data && this.fieldInstance.data.skipInput && (u += " skip-input"), this.$container = $("<div class='" + u + "'></div>").attr("data-key", t.key).data("ctrl", this).data("inst", t).appendTo(a), this.internalRender(i || "hide" === this.fieldInstance.mode), this.koValue = ko.validatedObservable(this.koValue), ko.applyBindings(this.koValue, this.$container.get(0))
    }, mediForm.ctrls.BaseCtrl.prototype.internalRender = function (e) {}, mediForm.ctrls.BaseCtrl.prototype.getDefaultValue = function () {
        function e(t) {
            var i = {};
            return $.each(t, function (t, a) {
                switch (a.type) {
                    case "arrayOfValue":
                    case "arrayOfObject":
                        i[a.key] = [];
                        break;
                    case "object":
                        i[a.key] = e(a.sub);
                        break;
                    default:
                        i[a.key] = null
                }
            }), i
        }
        return this.isSimpleValue ? {
            value: null
        } : "arrayOfValue" === this.fieldInstance.data.type ? [] : "arrayOfObject" === this.fieldInstance.data.type ? [] : e(this.fieldInstance.data.sub)
    }, mediForm.ctrls.BaseCtrl.prototype.hasError = function () {
        return !this.koValue.isValid()
    }, mediForm.ctrls.BaseCtrl.prototype.focusError = function () {
        this.isSimpleValue ? this.$container.find("input:eq(0), select:eq(0)").focus() : this.$container.find(".field-error:eq(0)").focus()
    }, mediForm.ctrls.BaseCtrl.prototype.getValue = function () {
        var e = ko.mapping.toJS(this.koValue);
        return this.isSimpleValue ? e.value : e
    }, mediForm.ctrls.BaseCtrl.prototype.correctValue = function (e) {
        function t(e, t) {
            "object" === e.type && "object" == typeof t ? i(e.sub, t) : "arrayOfObject" === e.type && $.isArray(t) && $.each(t, function (t, a) {
                i(e.sub, a)
            })
        }

        function i(e, i) {
            $.each(e, function (e, a) {
                if ("undefined" == typeof i[a.key] || null === i[a.key]) switch (a.type) {
                    case "arrayOfValue":
                    case "arrayOfObject":
                        i[a.key] = [];
                        break;
                    case "object":
                        i[a.key] = {}, t(a, i[a.key]);
                        break;
                    default:
                        i[a.key] = null
                } else t(a, i[a.key])
            })
        }
        t(this.fieldInstance.data, e)
    }, mediForm.ctrls.BaseCtrl.prototype.setValue = function (e) {
        var t = this.isSimpleValue ? {
            value: e
        } : e;
        ko.mapping.fromJS(t, this.koValue())
    }, mediForm.ctrls.BaseCtrl.prototype.hide = function () {
        this.isHidden = !0, this.$container.hide();
        var e = !0,
            t = this.$container.parents("tr:eq(0)");
        t.children().each(function () {
            var t = $(this).children("div.field"),
                i = t.data("ctrl");
            return i && !i.isHidden ? (e = !1, !1) : void 0
        }), e && t.hide()
    }, mediForm.ctrls.BaseCtrl.prototype.show = function () {
        this.isHidden = !1, this.$container.show(), this.$container.parents("tr:eq(0)").show()
    }, mediForm.ctrls.BaseCtrl.prototype.enable = function () {
        this.$container.find("input,textarea,select,button").prop("disabled", !1)
    }, mediForm.ctrls.BaseCtrl.prototype.disable = function () {
        this.$container.find("input,textarea,select,button").prop("disabled", !0)
    }, mediForm.ctrls.ctrlMap = {}, mediForm.ctrls.registerType = function (e, t) {
        if (mediForm.ctrls.ctrlMap[e]) throw "类型" + e + "已注册";
        mediForm.util.extend(t, mediForm.ctrls.BaseCtrl), mediForm.ctrls.ctrlMap[e] = t
    }, mediForm.ctrls.getTypeInstance = function (e) {
        var t = mediForm.ctrls.ctrlMap[e];
        if ("function" != typeof t) throw "未找到类型" + e;
        return new t
    }, mediForm.ctrls.renderEnd = function (e) {
        if (mediForm.layout.width % mediForm.layout.colCount !== 0) {
            var t = e.children("tr:last"),
                i = mediForm.layout.colCount - mediForm.layout.width % mediForm.layout.colCount;
            $("<td colspan='" + i + "' class='field-cell-" + i + " field-cell-empty'></td>").appendTo(t), mediForm.layout.width += i
        }
    }
}(), mediForm.ctrls.BodySurfaceAreaCtrl = function () {
        this.numPattern = /^\d+(\.\d+)?$/
    }, mediForm.ctrls.registerType("BodySurfaceArea", mediForm.ctrls.BodySurfaceAreaCtrl), mediForm.ctrls.BodySurfaceAreaCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = mediForm.util.getTextValidateTag(!1, "float"),
            n = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (n = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + n + " form-inline has-group'>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".shenGao'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>身高（cm）</div>"), e ? i.push("<div class='form-control' style='width:100px' data-bind='text: shenGao'></div>") : i.push("<input class='form-control' " + a + " data-bind='value: shenGao' style='width: 100px;'/>"), i.push("    </div>"), i.push("    <div class='error-msg' data-bind='validationMessage: shenGao'></div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".tiZhong'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>体重（kg）</div>"), e ? i.push("<div class='form-control' style='width:100px' data-bind='text: tiZhong'></div>") : i.push("<input class='form-control' " + a + " data-bind='value: tiZhong' style='width: 100px;'/>"), i.push("    </div>"), i.push("    <div class='error-msg' data-bind='validationMessage: tiZhong'></div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".tiBiaoMianJi'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>体表面积（m<sup>2</sup>）</div>"), i.push("        <div class='form-control' style='width:100px' data-bind='text: tiBiaoMianJi'></div>"), i.push("    </div>"), i.push("</div>"), i.push("</div>"), t.$container.html(i.join("")), t.koValue.tiBiaoMianJi = ko.pureComputed(function () {
            var e = this.shenGao(),
                i = this.tiZhong();
            return t.numPattern.test(e) && t.numPattern.test(i) ? (e = parseFloat(e), i = parseFloat(i), Math.round(Math.pow(i, .425) * Math.pow(e, .725) * 71.84) / 1e4) : "--"
        }, t.koValue)
    }, mediForm.ctrls.BodySurfaceAreaCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.BodySurfaceAreaCtrl.base.getValue.call(this);
        return e.shenGao = parseFloat(e.shenGao), e.tiZhong = parseFloat(e.tiZhong), e
    }, mediForm.ctrls.BodySurfaceAreaCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.BodySurfaceAreaCtrl.base.setValue.call(this, {
            shenGao: e.shenGao,
            tiZhong: e.tiZhong
        })
    }, mediForm.ctrls.CascadeDropDownListCtrl = function () {
        this.dispItems = {
            items: []
        }, this.dataMap = {}, this.isInitialized = !1, this.rawValue = null
    }, mediForm.ctrls.registerType("CascadeDropDownList", mediForm.ctrls.CascadeDropDownListCtrl), mediForm.ctrls.CascadeDropDownListCtrl.prototype.internalRender = function (e) {
        function t(e, i) {
            var n = [];
            a.dataMap[e] = n, $.each(i, function (i, a) {
                "string" == typeof a ? n.push(a) : (n.push(a.n), t(e + "|" + a.n, a.c))
            })
        }

        function i() {
            var e = a.$container.find("select");
            e.on("change", function () {
                var t = parseInt($(this).data("idx")),
                    i = "";
                if (t !== e.length - 1) {
                    for (var n = 0; t >= n; n++) i += "|" + e.eq(n).val();
                    var l = e.eq(t + 1),
                        o = "<option value=''>（请选择...）</option>" + (a.dataMap[i] ? s.render(a.dataMap[i]) : "");
                    l.html(o), a.rawValue && a.rawValue[l.data("key")] && (l.val(a.rawValue[l.data("key")]), a.rawValue[l.data("key")] = null), l.trigger("change")
                }
            });
            var t = "<option value=''>（请选择...）</option>" + s.render(a.dataMap[""]),
                i = e.eq(0);
            i.html(t), a.rawValue && a.rawValue[i.data("key")] && (i.val(a.rawValue[i.data("key")]), a.rawValue[i.data("key")] = null), i.trigger("change")
        }
        var a = this,
            n = [],
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>");
        $.map(a.fieldInstance.data.sub, function (e) {
            a.dispItems.items.push(e)
        });
        var l = "field-inline-control-noTitle";
        a.fieldInstance.layout.hideTitle || (l = "field-inline-control", n.push("<div class='field-inline-label'><label class='control-label'>" + a.fieldInstance.name + "</label></div>")), n.push("<div class='" + l + " form-inline has-group'>"), n.push("{{for items}}"), n.push("<div class='form-group medi-tip medi-compare' data-path='" + a.fieldInstance.key + ".{{:key}}'>"), n.push("    <div class='input-group'>"), n.push("        <div class='input-group-addon'>{{>name}}</div>"), e ? n.push("<div class='field-value form-control' data-bind='text: {{:key}}'></div>") : (n.push("        <select class='form-control' data-bind='value: {{:key}}' data-idx='{{:#index}}' data-key='{{:key}}'>"), n.push("            <option value=''>（请选择...）</option>"), n.push("        </select>")), n.push("    </div>"), n.push("</div>"), n.push("{{/for}}"), n.push("</div>"), a.$container.html($.templates(n.join("")).render(a.dispItems)), $.getJSON(a.fieldInstance.data.source).done(function (e) {
            t("", e), i(), a.isInitialized = !0
        })
    }, mediForm.ctrls.CascadeDropDownListCtrl.prototype.setValue = function (e) {
        this.rawValue = e, mediForm.ctrls.CascadeDropDownListCtrl.base.setValue.call(this, e), this.isInitialized && this.$container.find("select:eq(0)").trigger("change")
    }, mediForm.ctrls.CheckBoxCtrl = function () {}, mediForm.ctrls.registerType("CheckBox", mediForm.ctrls.CheckBoxCtrl), mediForm.ctrls.CheckBoxCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [];
        if (e) {
            var a = "field-inline-control-noTitle";
            t.fieldInstance.layout.hideTitle || (a = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + a + "'>"), i.push("<span class='field-value' data-bind='text: value'></span>")
        } else i.push("<label class='field-inline-control-noTitle'><input type='checkbox' data-bind='checked: key'/>"), t.fieldInstance.layout.hideTitle || i.push("<span  style='margin-left:10px'>" + t.fieldInstance.name + "</span>"), i.push("</label>");
        i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join(""))
    }, mediForm.ctrls.CheckBoxCtrl.prototype.getDefaultValue = function () {
        return {
            key: "是" === this.fieldInstance.config["default"],
            value: "是" === this.fieldInstance.config["default"] ? "是" : "否"
        }
    }, mediForm.ctrls.CheckBoxCtrl.prototype.getValue = function () {
        var e = ko.mapping.toJS(this.koValue).key;
        return e ? "是" : "否"
    }, mediForm.ctrls.CheckBoxCtrl.prototype.setValue = function (e) {
        var t = {
            value: e,
            key: "是" == e
        };
        ko.mapping.fromJS(t, this.koValue())
    }, mediForm.ctrls.CheckBoxCtrl.prototype.notifyAlways = function (e) {
        this.koValue().key.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.CheckBoxListCtrl = function () {}, mediForm.ctrls.registerType("CheckBoxList", mediForm.ctrls.CheckBoxListCtrl), mediForm.ctrls.CheckBoxListCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = this.fieldInstance.config.width ? this.fieldInstance.config.width : "100px",
            n = $.templates("<label class='checkbox-inline' style='width:" + a + ";'><input type='checkbox' value='{{attr: #data}}' data-bind='checked: result' />{{> #data}}</label>"),
            s = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (s = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + s + " checkList'" + (e ? ">" : " style='padding-top:7px'>")), e ? i.push("<span class='field-value' data-bind='text: dispResult'></span>") : i.push(n.render(mediForm.util.getEffectiveOptions(t.fieldInstance.config))), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key + "#").html(i.join("")), t.koValue.dispResult = ko.pureComputed(function () {
            return this.result().join(", ")
        }, t.koValue)
    }, mediForm.ctrls.CheckBoxListCtrl.prototype.getDefaultValue = function () {
        return {
            result: []
        }
    }, mediForm.ctrls.CheckBoxListCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.CheckBoxListCtrl.base.setValue.call(this, {
            result: e || []
        })
    }, mediForm.ctrls.CheckBoxListCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.CheckBoxListCtrl.base.getValue.call(this).result,
            t = mediForm.util.getEffectiveOptions(this.fieldInstance.config);
        return t.filter(function (t) {
            return e.indexOf(t) > -1
        })
    }, mediForm.ctrls.CheckBoxListCtrl.prototype.notifyAlways = function (e) {
        this.koValue().result.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.CheckBoxListCtrl.prototype.setOptions = function (e) {
        var t = this.getValue(),
            i = [],
            a = mediForm.util.getEffectiveOptions(this.fieldInstance.config),
            n = e.filter(function (e) {
                return a.indexOf(e) > -1
            }),
            s = n.length;
        return this.$container.find(".field-value").length > 0 ? s : (this.$container.find(".checkList").children().each(function () {
            var a = $(this),
                n = a.find("input").val();
            e.indexOf(n) > -1 ? (a.show(), t.indexOf(n) > -1 && i.push(n)) : a.hide()
        }), t.length !== i.length && this.setValue(i), s)
    }, mediForm.ctrls.ChemRegimentCtrl = function () {
        this.dispItems = {}, this.shortNames = {}, this.fangAnSuoXie = null, this.chongFuTianShu = null, this.numPattern = /^\d+(\.\d+)?$/
    }, mediForm.ctrls.registerType("ChemRegiment", mediForm.ctrls.ChemRegimentCtrl), mediForm.ctrls.ChemRegimentCtrl.prototype.internalRender = function (e) {
        function t(e, t, i) {
            var n = e.skipInput ? " skip-input" : "";
            if (t) a.push("<span class='field-value' data-bind='text: " + e.key + "'></span>");
            else if ($.isArray(e.options))
                if (e.allowFill) {
                    if (a.push("<div class='input-group dropdown" + n + "'>"), a.push(" <input type='text' class='form-control' data-bind='value: " + e.key + "' />"), a.push(" <div class='input-group-btn'>"), a.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), a.push("         <span class='caret'></span>"), a.push("     </button>"), a.push("     <ul class='dropdown-menu pull-right' role='menu'>"), i) {
                        var o = $.map(e.options, function (e) {
                            return e.full
                        });
                        o.unshift("（无）"), a.push(l.render(o))
                    } else a.push(l.render(e.options));
                    a.push("     </ul>"), a.push(" </div>"), a.push("</div>")
                } else a.push("<select class='form-control" + n + "' data-bind='value:" + e.key + "'>"), a.push("<option value=''>（请选择...）</option>"), a.push(s.render(e.options)), a.push("</select>");
            else a.push("<input type='text" + n + "' class='form-control' data-bind='value: " + e.key + "' "), a.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), a.push(" />")
        }
        var i = this,
            a = [],
            n = mediForm.util.findKeyInSub(i.fieldInstance.data, "huaLiaoYaoWu").sub,
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            l = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>"),
            o = this.fieldInstance.config || {};
        this.fangAnSuoXie = mediForm.util.findKeyInSub(i.fieldInstance.data, "fangAnSuoXie"), this.chongFuTianShu = mediForm.util.findKeyInSub(i.fieldInstance.data, "zhouQiChongFuTianShu"), this.dispItems = {}, $.map(n, function (e) {
            i.dispItems[e.key] = {}, $.map(e.sub, function (t) {
                i.dispItems[e.key][t.key] = t
            }), $.map(i.dispItems[e.key].tongYongMing.options, function (e) {
                i.shortNames[e.full] = e["short"]
            })
        });
        var d = "field-inline-control-noTitle";
        i.fieldInstance.layout.hideTitle || (d = "field-inline-control", a.push("<div class='field-inline-label'><label class='control-label'>" + i.fieldInstance.name + "</label></div>")), (this.chongFuTianShu || this.fangAnSuoXie) && (a.push("<div class='" + d + " form-inline has-group'>"), this.fangAnSuoXie && (a.push("<div class='form-group medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".fangAnSuoXie'><div class='input-group'>"), a.push("     <div class='input-group-addon'>" + this.fangAnSuoXie.name + "</div>"), a.push("     <div class='form-control' style='width:300px' data-bind='text: fangAnSuoXie'></div>"), a.push("</div></div>")), this.chongFuTianShu && (a.push("<div class='form-group medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".zhouQiChongFuTianShu'>"), a.push(" <div class='input-group'>"), a.push("     <div class='input-group-addon'>" + this.chongFuTianShu.name + "</div>"), e ? a.push("<div class='form-control' style='width:80px' data-bind='text: zhouQiChongFuTianShu'></div>") : a.push("<input class='form-control' " + mediForm.util.getTextValidateTag(!1, "integer") + " data-bind='value: zhouQiChongFuTianShu' style='width: 80px;'/>"), a.push(" </div>"), a.push(" <div class='error-msg' data-bind='validationMessage: zhouQiChongFuTianShu'></div>"), a.push("</div>")), a.push("</div>")), a.push("<table class='table table-hover chemRegi-table'>"), a.push(" <thead>"), a.push("     <th>化疗药物</th><th>通用名</th><th>缩写</th>"), o.hideJiLiang || a.push("<th style='width:80px'>剂量</th>"), o.hideDanWei || a.push("<th>单位</th>"), o.hideMeiPingMi || a.push("<th>/m<sup>2</sup></th>"), o.hideMeiGongJin || a.push("<th>/kg</th>"), o.hideYongFa || a.push("<th>用法</th>"), o.hideDiTian || a.push("<th style='width:120px'>第天</th>"), o.hidePinCi || a.push("<th>频次</th>"), a.push(" </thead>"), a.push(" <tbody>"), $.map(n, function (n) {
            var s = i.dispItems[n.key];
            a.push("<tr data-bind='with: huaLiaoYaoWu." + n.key + "'>"), a.push(" <td><div class='static'>" + n.name + "</div></td>"), a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".tongYongMing'>"), s.tongYongMing.allowFill = !0, t(s.tongYongMing, e, !0), a.push(" </td>"), a.push("<td style='width: 120px;' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".suoXie'>"), t(s.suoXie, e), a.push("</td>"), o.hideJiLiang || (a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".jiLiang'>"), t(s.jiLiang, e), a.push(" </td>")), o.hideDanWei || (a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".danWei'>"), t(s.danWei, e), a.push(" </td>")), o.hideMeiPingMi || a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".meiPingMi'><div class='static' data-bind='text: meiPingMi'></div></td>"), o.hideMeiGongJin || a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".meiGongJin'><div class='static' data-bind='text: meiGongJin'></div></td>"), o.hideYongFa || (a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".yongFa'>"), t(s.yongFa, e), a.push(" </td>")), o.hideDiTian || (a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".diTian'>"), t(s.diTian, e), a.push(" </td>")), o.hidePinCi || (a.push(" <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".huaLiaoYaoWu." + n.key + ".pinCi'>"), t(s.pinCi, e), a.push(" </td>")), a.push("</tr>")
        }), a.push(" </tbody>"), a.push("</table>"), this.$container.html(a.join("")), this.$container.find("button.dropdown-toggle").dropdown(), this.$container.delegate("div.dropdown", "shown.bs.dropdown", function () {
            $(this).find("ul.dropdown-menu").outerWidth($(this).outerWidth())
        }).delegate("ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), $(this).parents(".dropdown:eq(0)").children("input").val($(this).text()).trigger("change")
        }), $.each(this.dispItems, function (e, t) {
            i.koValue.huaLiaoYaoWu[e].tongYongMing.subscribe(function (t) {
                var a = i.koValue().huaLiaoYaoWu[e];
                "（无）" === t ? (a.tongYongMing(""), a.suoXie("--")) : i.shortNames[t] && a.suoXie(i.shortNames[t])
            }), i.koValue.huaLiaoYaoWu[e].meiPingMi = ko.pureComputed(function () {
                var t = this.huaLiaoYaoWu[e].jiLiang();
                return g_form.reference.tiBiaoMianJi && g_form.reference.tiBiaoMianJi.tiBiaoMianJi && i.numPattern.test(t) ? Math.round(100 * parseFloat(t) / g_form.reference.tiBiaoMianJi.tiBiaoMianJi) / 100 : 0
            }, i.koValue), i.koValue.huaLiaoYaoWu[e].meiGongJin = ko.pureComputed(function () {
                var t = this.huaLiaoYaoWu[e].jiLiang();
                return g_form.reference.tiBiaoMianJi && g_form.reference.tiBiaoMianJi.tiZhong && i.numPattern.test(t) ? Math.round(100 * parseFloat(t) / g_form.reference.tiBiaoMianJi.tiZhong) / 100 : 0
            }, i.koValue)
        }), this.fangAnSuoXie && (i.koValue.fangAnSuoXie = ko.pureComputed(function () {
            var e = [];
            return $.each(this.huaLiaoYaoWu, function (t, i) {
                var a = i.suoXie();
                a && "--" !== a && e.push(a)
            }), e.join(" ")
        }, i.koValue))
    }, mediForm.ctrls.ChemRegimentCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.ChemRegimentCtrl.base.getValue.call(this);
        return this.chongFuTianShu && $.trim(e.zhouQiChongFuTianShu) && (e.zhouQiChongFuTianShu = parseInt(e.zhouQiChongFuTianShu)), $.each(e.huaLiaoYaoWu, function (e, t) {
            $.trim(t.jiLiang) && (t.jiLiang = parseFloat(t.jiLiang))
        }), e
    }, mediForm.ctrls.ChemRegimentCtrl.prototype.setValue = function (e) {
        var t = $.extend(!0, {}, e);
        this.correctValue(t), this.fangAnSuoXie && delete t.fangAnSuoXie, $.each(t.huaLiaoYaoWu, function (e, t) {
            delete t.suoXie, delete t.meiPingMi, delete t.meiGongJin
        }), mediForm.ctrls.ChemRegimentCtrl.base.setValue.call(this, t)
    }, mediForm.ctrls.ComboBoxCtrl = function () {}, mediForm.ctrls.registerType("ComboBox", mediForm.ctrls.ComboBoxCtrl), mediForm.ctrls.ComboBoxCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>"),
            n = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (n = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), 1 == t.fieldInstance.layout.width ? (t.fieldInstance.config.unit ? (i.push("<div style='width:60px;float:right;padding:7px 0px 0 5px;word-wrap:break-word;'><label class='control-label'>" + t.fieldInstance.config.unit + "</label></div>"), i.push("<div class='" + n + "' style='margin-right:60px;'>")) : i.push("<div class='" + n + "'>"), e ? i.push("<span class='field-value' data-bind='text: value'></span>") : (i.push("<div class='input-group dropdown'>"), i.push(" <input type='text' class='form-control' data-bind='value: value' />"), i.push(" <div class='input-group-btn'>"), i.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), i.push("         <span class='caret'></span>"), i.push("     </button>"), i.push("     <ul class='dropdown-menu pull-right' role='menu'>"), i.push(a.render(mediForm.util.getEffectiveOptions(t.fieldInstance.config))), i.push("     </ul>"), i.push(" </div>"), i.push("</div>")), i.push("</div>")) : (t.fieldInstance.config.unit ? i.push("<div class='" + n + " clearfix' >") : i.push("<div class='" + n + "'>"), e ? i.push("<span class='field-value' data-bind='text: value'></span>") : (t.fieldInstance.config.unit ? i.push("<div class='input-group dropdown' style='float:left;'>") : i.push("<div class='input-group dropdown'>"), i.push(" <input type='text' class='form-control' data-bind='value: value' />"), i.push(" <div class='input-group-btn'>"), i.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), i.push("         <span class='caret'></span>"), i.push("     </button>"), i.push("     <ul class='dropdown-menu pull-right' role='menu'>"), i.push(a.render(mediForm.util.getEffectiveOptions(t.fieldInstance.config))), i.push("     </ul>"), i.push(" </div>"), i.push("</div>")), t.fieldInstance.config.unit && i.push("<div style='width:60px;float:left;padding:7px 0px 0 5px;word-wrap:break-word;'><label class='control-label'>" + t.fieldInstance.config.unit + "</label></div>"), i.push("</div>")), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join(""));
        var s = t.$container.find("ul.dropdown-menu"),
            l = t.$container.find("div.dropdown"),
            o = t.$container.find("input");
        t.$container.find("button.dropdown-toggle").dropdown(), l.on("shown.bs.dropdown", function () {
            s.outerWidth(l.outerWidth())
        }).delegate("ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), o.val($(this).text()).trigger("change")
        })
    }, mediForm.ctrls.ComboBoxCtrl.prototype.getDefaultValue = function () {
        return {
            value: this.fieldInstance.config["default"] || ""
        }
    }, mediForm.ctrls.ComboBoxCtrl.prototype.notifyAlways = function (e) {
        this.koValue().value.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.ComboBoxCtrl.prototype.setOptions = function (e) {
        var t = this.getValue(),
            i = !1,
            a = "",
            n = mediForm.util.getEffectiveOptions(this.fieldInstance.config),
            s = e.filter(function (e) {
                return n.indexOf(e) > -1
            }),
            l = s.length + 1;
        return this.$container.find(".field-value").length > 0 ? l : (this.$container.find("ul.dropdown-menu").children().each(function () {
            var n = $(this),
                s = n.find("a").text(),
                l = "none" === n.css("display"),
                o = e.indexOf(s) < 0;
            l || s !== t || (i = !0, o || (a = t)), o ? n.hide() : n.show()
        }), t !== a && i && this.setValue(a), l)
    }, mediForm.ctrls.ConnectorMultiTextCtrl = function () {
        this.dispItems = []
    }, mediForm.ctrls.registerType("ConnectorMultiText", mediForm.ctrls.ConnectorMultiTextCtrl), mediForm.ctrls.ConnectorMultiTextCtrl.prototype.internalRender = function (e) {
        function t(e, t, i) {
            0 == e ? n.push("<" + t + ' style="' + i + '">' + a.fieldInstance.data.config.symbolA + "</" + t + ">") : n.push("<" + t + ' style="' + i + '">' + a.fieldInstance.data.config.symbolB + "</" + t + ">")
        }

        function i(e) {
            var t;
            return "" != e.width ? (t = "width", t + ":" + parseInt(e.width) + "px") : (t = "min-width", t + ":50px")
        }
        var a = this,
            n = [],
            s = "field-inline-control-noTitle";
        a.fieldInstance.layout.hideTitle || (s = "field-inline-control", n.push('<div class="field-inline-label"><label class="control-label">' + a.fieldInstance.name + "</label></div>")), this.dispItems = [], $.map(a.fieldInstance.data.sub, function (e) {
            a.dispItems.push(e)
        }), n.push('<div class="' + s + ' form-inline has-group">'), $.map(this.dispItems, function (s, l) {
            var o = mediForm.util.getTextValidateTag(!1, s.type);
            e ? (n.push('<div class="form-group medi-tip medi-compare" data-path="' + a.fieldInstance.key + "." + s.key + '" style="margin-right:0;">'), n.push('     <span style="padding:6px 4px" data-bind="text:' + s.key + '"></span>'), l !== a.dispItems.length - 1 && t(l, "span", "padding:6px 4px;")) : s.readonly ? (n.push('<div class="form-group" style="margin-right:0;">'), n.push('     <div style="padding:6px 4px;border:1px solid #ccc;background:#eee;height:34px;" data-bind="text:' + s.key + '"></div>')) : (n.push('<div class="form-group medi-tip medi-compare" data-path="' + a.fieldInstance.key + "." + s.key + '" style="margin-right:0;' + i(s) + '">'), n.push('     <input type="text" class="form-control" ' + o + ' placeholder="' + s.name + '" data-bind="value:' + s.key + '"  style="' + i(s) + '">'), n.push('     <div class="error-msg" data-bind="validationMessage:' + s.key + '"></div>')), n.push("</div>"), e || l === a.dispItems.length - 1 || (n.push('<div class="form-group" style="margin-right:0;">'), t(l, "div", "padding:6px 4px;border:1px solid #ccc;background:#eee;height:34px;"), n.push("</div>"))
        }), n.push("</div>"), this.$container.html(n.join("")), this.$container.find("input.form-control").css({
            "border-radius": "0"
        }), this.$container.find("input.form-control:last").css({
            "border-radius": "0 4px 4px 0"
        }), this.$container.find("input.form-control:first").css({
            "border-radius": "4px 0  0 4px"
        })
    }, mediForm.ctrls.ConnectorMultiTextCtrl.prototype.getDefaultValue = function () {
        var e = this,
            t = 0,
            i = mediForm.ctrls.ConnectorMultiTextCtrl.base.getDefaultValue.call(this);
        return $.each(i, function (a, n) {
            i[a] = e.fieldInstance.data.sub[t].defaultValue ? e.fieldInstance.data.sub[t].defaultValue : null, t++
        }), i
    }, mediForm.ctrls.DateCtrl = function () {}, mediForm.ctrls.registerType("Date", mediForm.ctrls.DateCtrl), mediForm.ctrls.DateCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (a = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + a + "'>"), e ? i.push("<span class='field-value' data-bind='text: value'></span>") : i.push("<input type='text' pattern='^\\d{4}-\\d{2}-\\d{2}$' class='form-control calendar'" + (this.fieldInstance.required ? " required" : "") + " data-bind='value: value' />"), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join("")), t.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), window.setTimeout(function () {
            t.$container.find("input.calendar").datepicker("update")
        }, 50)
    }, mediForm.ctrls.DateCtrl.prototype.getDefaultValue = function () {
        if (this.fieldInstance.config && "[today]" === this.fieldInstance.config["default"]) {
            var e = new Date,
                t = e.getFullYear(),
                i = e.getMonth() + 1,
                a = e.getDate();
            return {
                value: t + "-" + (10 > i ? "0" : "") + i + "-" + (10 > a ? "0" : "") + a
            }
        }
        return {
            value: ""
        }
    }, mediForm.ctrls.DateCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.DateCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.DeathInfoCtrl = function () {}, mediForm.ctrls.registerType("DeathInfo", mediForm.ctrls.DeathInfoCtrl), mediForm.ctrls.DeathInfoCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (a = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + a + "' form-inline has-group>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".shiFouSiWang'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>是否死亡</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: shiFouSiWang'></div>") : (i.push("<select class='form-control' style='width:80px' data-bind='value: shiFouSiWang'>"), i.push("     <option value='否'>否</option>"), i.push("     <option value='是'>是</option>"), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".siWangShiJian' data-bind='visible: shiFouSiWang() === \"是\"'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>死亡时间</div>"), e ? i.push("<div class='form-control' style='width:120px' data-bind='text: siWangShiJian'></div>") : i.push("<input class='form-control calendar' data-bind='value: siWangShiJian' style='width: 120px;'/>"), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".os' data-bind='visible: shiFouSiWang() === \"是\"'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>OS</div>"), i.push("        <div class='form-control' style='width:100px' data-bind='text: os'></div>"), i.push("    </div>"), i.push("</div>"), i.push("</div>"), this.$container.html(i.join("")), this.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), this.koValue.shiFouSiWang.subscribe(function (e) {
            "否" === e && t.koValue().siWangShiJian(null)
        }), this.koValue.os = ko.pureComputed(function () {
            if ("否" === this.shiFouSiWang()) return null;
            var e = this.siWangShiJian();
            return e && g_form.reference.zhiLiaoKaiShi ? Math.round((Date.parse(e) - Date.parse(g_form.reference.zhiLiaoKaiShi)) / 864e5 * 1200 / 365) / 100 : null
        }, this.koValue)
    }, mediForm.ctrls.DeathInfoCtrl.prototype.getDefaultValue = function () {
        return {
            shiFouSiWang: "否",
            siWangShiJian: null,
            os: null
        }
    }, mediForm.ctrls.DeathInfoCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.DeathInfoCtrl.base.setValue.call(this, {
            shiFouSiWang: e.shiFouSiWang,
            siWangShiJian: e.siWangShiJian
        }), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.DocumentsCtrl = function () {}, mediForm.ctrls.registerType("Documents", mediForm.ctrls.DocumentsCtrl), mediForm.ctrls.DocumentsCtrl.prototype.internalRender = function (e) {
        var t, i = this,
            a = [],
            n = g_form.resultId ? g_form.resultId : g_form.newId;
        i.fieldInstance.layout.hideTitle || a.push("<div><label class='control-label'>" + i.fieldInstance.name + "</label></div>"), a.push("<div class='fileContainer'>"), e || (a.push("<div class='action-addfile  list-group text-center'"), a.push(" style='border: 1px dashed #777;height: 42px;line-height: 42px;margin-bottom: 5px;border-radius: 4px;'"), a.push(" data-bind='click: addItem'><span class='glyphicon glyphicon-plus'></span></div>")), a.push("<div class='text-center' data-bind='visible: !result().length'>暂无附件</div>"), a.push(" <ul class='list-group' style='margin-bottom:0;height:200px;overflow-y:auto;'   data-bind='foreach: result'>"), a.push("     <li class='list-group-item text-primary' >"), e || a.push("<a href='javascript:void(0)' data-bind='click: $parent.removeItem' style='vertical-align:middle;padding:8px; padding-left:0;' title='删除'><span class='glyphicon glyphicon-remove'></span></a>"), a.push("<span data-bind='text: docName'></span>"), a.push("</li>"), a.push(" </ul>"), a.push("</div>"), e || (a.push("<div class='modal-upload file-upload modal fade' tabindex='-1' role='dialog' aria-hidden='true' >"), a.push(" <div class='box'>"), a.push("    <div class='modal-dialog'>"), a.push("        <div class='modal-content'>"), a.push("            <div class='modal-header'>"), a.push("                <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>关闭</button>"), a.push("                <div>"), a.push("                    <h4 class='modal-title'>上传文件</h4>"), a.push("                </div>"), a.push("            </div>"), a.push("            <div class='modal-body'>"), a.push("                <div class='form-horizontal'>"), a.push("                    <div class='form-group'>"), a.push("                        <label class='col-sm-2'>选择文件</label>"), a.push("                        <div class='col-sm-10'>"), a.push("                            <input type='file' class='file' data-show-upload='false' multiple='true'/>"), a.push("                        </div>"), a.push("                    </div>"), a.push("                    <div class='progress progress-striped'>"), a.push("                        <div class='bar progress-bar progress-bar-striped active' style='width: 0%; height: 15px;'>&nbsp;</div>"), a.push("                    </div>"), a.push("                </div>"), a.push("            </div>"), a.push("            <div class='modal-footer'>"), a.push("                <button type='button' class='btn btn-upload btn-primary'>上传</button>"), a.push("            </div>"), a.push("        </div>"), a.push("    </div>"), a.push(" </div>"), a.push("</div>")), i.$container.addClass("medi-tip medi-compare medi-metadata-only").attr("data-path", i.fieldInstance.key + ".result").html(a.join("")), t = i.$container.find(".modal-upload"), i.$container.find(".file").fileinput({
            showPreview: !1,
            allowedFileExtensions: i.fieldInstance.config.options
        }), i.koValue.addItem = function () {
            t.find(":file").fileinput("clear"), t.modal("show")
        }, i.koValue.removeItem = function (e) {
            event.preventDefault(), i.koValue().result.remove(e)
        }, i.$container.delegate(".fileContainer li", "click", function (e) {
            e.preventDefault();
            var t = ko.mapping.toJS(i.koValue).result[$(this).index()],
                a = t.docId,
                n = t.docName;
            window.open("/api/Attachment/?id=" + a + "&diseaseId=" + g_form.diseaseId + "&formResultId=" + g_form.resultId + "&origName=" + n)
        }), t.delegate(".btn-upload", "click", function (e) {
            function a(e, a) {
                function n(e) {
                    if ($.inArray(e, m) > -1) {
                        var t = e.lastIndexOf("_("),
                            i = e.lastIndexOf(")."),
                            a = e.lastIndexOf("."),
                            s = e.substring(0, a),
                            l = e.substring(a + 1);
                        if (t > -1 && i > -1) {
                            var o = parseInt(e.substring(t + 2, i)) + 1;
                            return n(s.split("_(").shift() + "_(" + o + ")." + l)
                        }
                        return n(s + "_(1)." + l)
                    }
                    return e
                }
                var s = new Date,
                    o = s.getTime() + "_" + e,
                    u = a.name.split(".").pop(),
                    h = o + "." + u,
                    m = $.map(ko.mapping.toJS(i.koValue).result, function (e) {
                        return e.docName
                    });
                return $.ajax({
                    url: "/api/Attachment?id=" + h + r + "&r=" + Math.random(),
                    type: "POST",
                    data: a,
                    cache: !1,
                    contentType: !1,
                    processData: !1
                }).complete(function () {
                    l++, l === d && p.resolve()
                }).done(function (e) {
                    t.find(".bar").width(parseInt(l / d * 100) + "%"), e.success && (c++, i.koValue().result.push({
                        docId: h,
                        docName: n(a.name)
                    }))
                })
            }
            e.preventDefault();
            var s = $(this),
                l = 0,
                o = t.find(":file")[0].files,
                d = o.length,
                r = "&diseaseId=" + g_form.diseaseId + "&formResultId=" + n,
                u = $.Deferred().resolve().promise(),
                p = $.Deferred(),
                c = 0;
            return 0 == o.length ? void t.modal("hide") : (s.prop("disabled", !0), t.find(".progress").show(), $.each(o, function (e, t) {
                u = u.then(function () {
                    return a(e, t)
                })
            }), void p.done(function () {
                l > c && alert("部分文件上传失败，请重新选择"), s.prop("disabled", !1), t.modal("hide")
            }).always(function () {
                t.find(".progress").hide(), t.find(".bar").width("0%")
            }))
        }).on("shown.bs.modal", function (e) {
            t.find(".btn-upload").prop("disabled", !1), t.find(".bar").width("0%"), t.find(".progress").hide()
        })
    }, mediForm.ctrls.DocumentsCtrl.prototype.getDefaultValue = function () {
        return {
            result: []
        }
    }, mediForm.ctrls.DropDownListCtrl = function () {}, mediForm.ctrls.registerType("DropDownList", mediForm.ctrls.DropDownListCtrl), mediForm.ctrls.DropDownListCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = mediForm.util.getEffectiveOptions(t.fieldInstance.config),
            n = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            s = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (s = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), t.fieldInstance.config.unit ? (i.push("<div style='width:60px;float:right;padding:7px 0px 0 5px;word-wrap:break-word;'><label class='control-label'>" + t.fieldInstance.config.unit + "</label></div>"), i.push("<div class='" + s + "' style='margin-right:60px;'>")) : i.push("<div class='" + s + "'>"), e ? i.push("<span class='field-value' data-bind='text: value'></span>") : (i.push("<select class='form-control' data-bind='value: value'>"), i.push("		<option value=''>（请选择...）</option>"), i.push(n.render(a)), i.push("</select>")), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join(""))
    }, mediForm.ctrls.DropDownListCtrl.prototype.getDefaultValue = function () {
        return {
            value: this.fieldInstance.config["default"] || ""
        }
    }, mediForm.ctrls.DropDownListCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.DropDownListCtrl.base.setValue.call(this, e)
    }, mediForm.ctrls.DropDownListCtrl.prototype.notifyAlways = function (e) {
        this.koValue().value.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.DropDownListCtrl.prototype.setOptions = function (e) {
        var t = this.getValue(),
            i = !1,
            a = mediForm.util.getEffectiveOptions(this.fieldInstance.config),
            n = a.filter(function (a) {
                var n = e.indexOf(a) > -1;
                return n && a === t && (i = !0), n
            }),
            s = n.length,
            l = this.$container.find("select"),
            o = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>");
        return this.$container.find(".field-value").length > 0 ? s : (l.html("<option value=''>（请选择...）</option>" + o.render(n)).val(i ? t : ""), i || l.trigger("change"), n.length)
    }, mediForm.ctrls.DropDownListSearchCtrl = function () {}, mediForm.ctrls.registerType("DropDownListSearch", mediForm.ctrls.DropDownListSearchCtrl), mediForm.ctrls.DropDownListSearchCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = mediForm.util.getEffectiveOptions(t.fieldInstance.config),
            n = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>");
        console.dir(t);
        var s = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (s = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + s + "'>"), e ? i.push("<span class='field-value' data-bind='text: value'></span>") : (i.push("<select class='form-control selectpicker' data-bind='value: value'>"), i.push("		<option value=''>（请选择...）</option>"), i.push(n.render(a)), i.push("</select>")), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join("")), t.$container.find(".selectpicker").selectpicker({
            liveSearch: !0,
            noneResultsText: "无相关数据",
            size: 10
        }).selectpicker("refresh")
    }, mediForm.ctrls.DropDownListSearchCtrl.prototype.getDefaultValue = function () {
        return {
            value: this.fieldInstance.config["default"] || ""
        }
    }, mediForm.ctrls.DropDownListSearchCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.DropDownListSearchCtrl.base.setValue.call(this, e), this.$container.find(".selectpicker").selectpicker("val", e)
    }, mediForm.ctrls.DropDownListSearchCtrl.prototype.notifyAlways = function (e) {
        this.koValue().value.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.DropDownListSearchCtrl.prototype.setOptions = function (e) {
        var t = this.getValue(),
            i = !1,
            a = mediForm.util.getEffectiveOptions(this.fieldInstance.config),
            n = a.filter(function (a) {
                var n = e.indexOf(a) > -1;
                return n && a === t && (i = !0), n
            }),
            s = n.length,
            l = this.$container.find("select"),
            o = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>");
        return this.$container.find(".field-value").length > 0 ? s : (l.html("<option value=''>（请选择...）</option>" + o.render(n)).val(i ? t : ""), i || l.trigger("change"), this.$container.find(".selectpicker").selectpicker("refresh"), n.length)
    }, mediForm.ctrls.DropDownListVTCtrl = function () {}, mediForm.ctrls.registerType("DropDownListVT", mediForm.ctrls.DropDownListVTCtrl), mediForm.ctrls.DropDownListVTCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = [{
                value: "（请选择...)",
                text: "（请选择...)"
            }],
            n = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#' data-value='{{attr: value}}'>{{> text}}</a></li>");
        $.map(this.fieldInstance.config.options, function (e) {
            a.push(e)
        });
        var s = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (s = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + s + "'>"), e ? i.push("<span class='field-value-span' data-bind='text: value'></span>") : (i.push("<div class='dropdown dropdownvt'>"), i.push("   <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), i.push("       <span class='field-value-span' data-bind='text: value'></span>"), i.push("       <div class='caret'></div>"), i.push("   </button>"), i.push("   <ul class='dropdown-menu' role='menu'>"), i.push(n.render(a)), i.push("   </ul>"), i.push("</div>")), i.push("</div>"), this.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join("")), t.fieldInstance.config.showTextInsteadOfValue && t.koValue.value.subscribe(function (e) {
            var i = "";
            $.each(t.fieldInstance.config.options, function (t, a) {
                return a.value == e ? (i = a.text, !1) : void 0
            }), t.$container.find(".field-value-span").text(i)
        }), this.$container.find("button.dropdown-toggle").dropdown(), this.$container.delegate("ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), t.koValue().value($(this).data("value")), t.fieldInstance.config.showTextInsteadOfValue && t.$container.find(".field-value-span").text($(this).text())
        })
    }, mediForm.ctrls.DropDownListVTCtrl.prototype.getDefaultValue = function () {
        return {
            value: this.fieldInstance.config["default"] ? this.fieldInstance.config["default"] : "（请选择...)"
        }
    }, mediForm.ctrls.DropDownListVTCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.DropDownListVTCtrl.base.getValue.call(this);
        return "（请选择...)" === e ? "" : e + ""
    }, mediForm.ctrls.DropDownListVTCtrl.prototype.setValue = function (e) {
        if (mediForm.ctrls.DropDownListVTCtrl.base.setValue.call(this, e ? e : "（请选择...)"), this.fieldInstance.config.showTextInsteadOfValue && e) {
            var t = this,
                i = "";
            $.each(this.fieldInstance.config.options, function (t, a) {
                return a.value == e ? (i = a.text, !1) : void 0
            }), t.$container.find(".field-value-span").text(i)
        }
    }, mediForm.ctrls.DropDownListVTCtrl.prototype.notifyAlways = function (e) {
        this.koValue().value.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.Level4EffectCtrl = function () {
        this.dispItems = {
            items: []
        }, this.levelNames = ["0级", "I级", "II级", "III级", "IV级"]
    }, mediForm.ctrls.registerType("Level4Effect", mediForm.ctrls.Level4EffectCtrl), mediForm.ctrls.Level4EffectCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = {};
        t.fieldInstance.config && t.fieldInstance.config.levelNames && (t.levelNames = t.fieldInstance.config.levelNames), t.dispItems.items = [], $.map(t.fieldInstance.data.sub, function (e) {
            a[e.key] = !0, t.dispItems.items.push(e), e.summary && (e.levels = t.levelNames)
        }), $.map(t.dispItems.items, function (e) {
            e.summary && (e.summary = $.grep(e.summary, function (e) {
                return !!a[e]
            }))
        }), t.dispItems.items = $.grep(t.dispItems.items, function (e) {
            return "undefined" == typeof e.summary || e.summary.length > 0
        }), t.fieldInstance.layout.hideTitle || i.push("<div><span class='field-title'>" + t.fieldInstance.name + "</span></div>"), i.push("<table class='table table-hover lv4Effect-table'>"), i.push("    <thead>"), i.push("        <tr><th class='item'>反应指标</th>"), $.each(t.levelNames, function (e, t) {
            i.push("<th class='value'>" + t + "</th>")
        }), i.push("    </tr></thead>"), i.push("    <tbody>"), i.push("    {{for items}}"), i.push("        <tr class='{{if summary}}info{{else}}normal{{/if}}'>"), i.push("            <td class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".{{:key}}'>{{:name}}</td>"), i.push("            {{for levels}}"), i.push("            <td class='medi-compare' data-path='" + t.fieldInstance.key + ".{{:#parent.parent.data.key}}'>"), i.push("                <label class='radio-inline' {{if !#data}}style='display:none'{{/if}}>"), i.push("                <input type='radio' name='" + t.fieldInstance.key + "_{{: #parent.parent.data.key}}' "), i.push("                    value='{{:#index}}' data-bind='checked: {{:#parent.parent.data.key}}'/>"), i.push("                {{: #data}}"), i.push("            </label></td>"), i.push("            {{/for}}"), i.push("        </tr>"), i.push("    {{/for}}"), i.push("    </tbody>"), i.push("</table>"), this.$container.data("readonly", e).html($.templates(i.join("")).render(this.dispItems)), e ? this.$container.find("input").prop("disabled", !0) : $.map(this.dispItems.items, function (e) {
            e.summary || t.koValue[e.key].subscribe(function () {
                t.updateRadioState()
            })
        })
    }, mediForm.ctrls.Level4EffectCtrl.prototype.updateRadioState = function () {
        var e = this,
            t = this.$container.data("readonly");
        $.map(this.dispItems.items, function (i) {
            if ($.isArray(i.summary)) {
                var a = 0,
                    n = parseInt(e.koValue()[i.key]());
                $.map(i.summary, function (t) {
                    var i = parseInt(e.koValue()[t]());
                    i > a && (a = i)
                }), a > n && e.koValue()[i.key](a.toString()), e.$container.find("input[name='" + e.fieldInstance.key + "_" + i.key + "']").each(function () {
                    $(this).prop("disabled", t || parseInt($(this).val()) < a)
                })
            }
        })
    }, mediForm.ctrls.Level4EffectCtrl.prototype.getDefaultValue = function () {
        var e = mediForm.ctrls.Level4EffectCtrl.base.getDefaultValue.call(this);
        return $.each(e, function (t, i) {
            e[t] = "0"
        }), e
    }, mediForm.ctrls.Level4EffectCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.Level4EffectCtrl.base.getValue.call(this),
            t = {};
        return $.map(this.dispItems.items, function (i) {
            t[i.key] = parseInt(e[i.key])
        }), t
    }, mediForm.ctrls.Level4EffectCtrl.prototype.setValue = function (e) {
        $.map(this.dispItems.items, function (t) {
            e[t.key] = "undefined" == typeof e[t.key] || null === e[t.key] ? "" : e[t.key].toString()
        }), mediForm.ctrls.Level4EffectCtrl.base.setValue.call(this, e), this.updateRadioState()
    }, mediForm.ctrls.LungCancerOperationCtrl = function () {
        this.propItems = {}
    }, mediForm.ctrls.registerType("LungCancerOperation", mediForm.ctrls.LungCancerOperationCtrl), mediForm.ctrls.LungCancerOperationCtrl.prototype.internalRender = function (e) {
        function t(e, t) {
            t ? a.push("<span class='field-value' data-bind='text: " + e.key + "'></span>") : $.isArray(e.options) ? (a.push("<select class='form-control' data-bind='value:" + e.key + "'>"), a.push("<option value=''>（请选择...）</option>"), a.push(s.render(e.options)), a.push("</select>")) : (a.push("<input type='text' class='form-control"), "date" === e.type && a.push(" calendar"), a.push("' data-bind='value: " + e.key + "' "), a.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), a.push(" />"))
        }
        var i = this,
            a = [],
            n = e ? " disabled='disabled'" : "",
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            l = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: fenHua' />{{> #data}}</label></div>"),
            o = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: bingLiLeiXing' />{{> #data}}</label></div>");
        $.map(this.fieldInstance.data.sub, function (e) {
            "linBaJieQinFan" === e.key ? (i.propItems.linBaJieQinFan = {
                _self: e
            }, $.map(e.sub, function (e) {
                i.propItems.linBaJieQinFan[e.key] = e
            })) : i.propItems[e.key] = e
        }), i.fieldInstance.layout.hideTitle || a.push("<div><span class='field-title'>" + this.fieldInstance.name + "</span></div>"), a.push("<table class='table table-bordered operation-table'><tbody>"), a.push(" <tr>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shouShuRiQi'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shouShuRiQi.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shouShuRiQi, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td colspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shouShuMingCheng'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shouShuMingCheng.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shouShuMingCheng, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shuZhe'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shuZhe.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shuZhe, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td colspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shiFouCanLiuZhongLiu'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shiFouCanLiuZhongLiu.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shiFouCanLiuZhongLiu, e), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr>"), a.push("     <td rowspan='2' style='width:150px' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".zhongLiuBuWei'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.zhongLiuBuWei.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push("             <table class='table table-condensed table-bordered operation-buwei'><tbody>"), a.push("                 <tr>"), a.push("                     <td></td><td>左肺</td><td>右肺</td>"), a.push("                 </tr>"), a.push("                 <tr>"), a.push("                     <td></td>"), a.push("                     <td><input type='checkbox' value='左' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                     <td><input type='checkbox' value='右' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                 </tr>"), a.push("                 <tr>"), a.push("                     <td>上</td>"), a.push("                     <td><input type='checkbox' value='左上' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                     <td><input type='checkbox' value='右上' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                 </tr>"), a.push("                 <tr>"), a.push("                     <td>中</td>"), a.push("                     <td><input type='checkbox' value='左中' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                     <td><input type='checkbox' value='右中' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                 </tr>"), a.push("                 <tr>"), a.push("                     <td>下</td>"), a.push("                     <td><input type='checkbox' value='左下' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                     <td><input type='checkbox' value='右下' data-bind='checked: zhongLiuBuWei'" + n + " /></td>"), a.push("                 </tr>"), a.push("             </tbody></table>"), a.push("         </div>"), a.push("     </td>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".fenHua'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.fenHua.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(l.render(this.propItems.fenHua.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".bingLiLeiXing'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.bingLiLeiXing.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(o.render(this.propItems.bingLiLeiXing.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".feiNeiZhuanYiZao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.feiNeiZhuanYiZao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.feiNeiZhuanYiZao, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".xiongShui'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.xiongShui.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.xiongShui, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".daXiao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.daXiao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.daXiao, e), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr>"), a.push("     <td colspan='3'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.linBaJieQinFan._self.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push("             <table class='table table-hover medi-compare' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#'>"), a.push("                 <thead>"), a.push("                     <th class='perm-edit' style='width:10px'></th>"), a.push("                     <th class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.zuShu'>组数</th>"), a.push("                     <th colspan='2' class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.fenZi'>淋巴结数</th>"), a.push("                     <th class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.fenMu'></th>"), a.push("                 </thead>"), a.push("                 <tbody data-bind='foreach: linBaJieQinFan'>"), a.push("                     <tr>"), a.push("                         <td class='td-del perm-edit'>"), a.push("                             <a href='javascript:void(0)' data-bind='click: $parent.removeItem' title='删除'>"), a.push("                             <span class='glyphicon glyphicon-remove'></span></a>"), a.push("                         </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.zuShu, e), a.push("                         </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.fenZi, e), a.push("                         </td>"), a.push("                         <td style='width:20px'> / </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.fenMu, e), a.push("                         </td>"), a.push("                 </tbody>"), a.push("                 <tfoot><tr>"), a.push("                     <td colspan='99' class='td-add perm-edit' style='text-align:left'><a href='javascript:void(0)' data-bind='click: addItem'>"), a.push("                         <span class='glyphicon glyphicon-plus'></span> 添加新项</a></td>"), a.push("                 </tr></tfoot>"), a.push("             </table>"), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push("</tbody></table>"), this.$container.html(a.join("")), i.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), this.koValue.addItem = function () {
            i.koValue().linBaJieQinFan.push({
                zuShu: ko.observable(null),
                fenZi: ko.observable(null),
                fenMu: ko.observable(null)
            })
        }, this.koValue.removeItem = function (e) {
            i.koValue().linBaJieQinFan.remove(e)
        }, this.koValue.zhongLiuBuWei.subscribe(function (e) {
            for (var t = !1, a = !1, n = !1, s = !1, l = e.length, o = e.length - 1; o >= 0; o--) switch (e[o]) {
                case "左":
                    t = !0;
                    break;
                case "右":
                    a = !0;
                    break;
                case "左上":
                case "左中":
                case "左下":
                    n = !0;
                    break;
                case "右上":
                case "右中":
                case "右下":
                    s = !0
            }!t && n && e.push("左"), !a && s && e.push("右"), e.length > l && i.koValue().zhongLiuBuWei(e)
        })
    }, mediForm.ctrls.LungCancerOperationCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.LungCancerOperationCtrl.base.getValue.call(this);
        return $.each(e.linBaJieQinFan, function (e, t) {
            "" !== t.zuShu && (t.zuShu = parseInt(t.zuShu)), "" !== t.fenZi && (t.fenZi = parseInt(t.fenZi)), "" !== t.fenMu && (t.fenMu = parseInt(t.fenMu))
        }), e
    }, mediForm.ctrls.LungCancerOperationCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.LungCancerOperationCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.OvarianCancerOperationCtrl = function () {
        this.propItems = {}
    }, mediForm.ctrls.registerType("OvarianCancerOperation", mediForm.ctrls.OvarianCancerOperationCtrl), mediForm.ctrls.OvarianCancerOperationCtrl.prototype.internalRender = function (e) {
        function t(e, t) {
            t ? a.push("<span class='field-value' data-bind='text: " + e.key + "'></span>") : $.isArray(e.options) ? (a.push("<select class='form-control' data-bind='value:" + e.key + "'>"), a.push("<option value=''>（请选择...）</option>"), a.push(s.render(e.options)), a.push("</select>")) : (a.push("<input type='text' class='form-control"), "date" === e.type && a.push(" calendar"), a.push("' data-bind='value: " + e.key + "' "), a.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), a.push(" />"))
        }
        var i = this,
            a = [],
            n = e ? " disabled='disabled'" : "",
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            l = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: zhongLiuBuWei' />{{> #data}}</label></div>"),
            o = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: fenHua' />{{> #data}}</label></div>"),
            d = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: bingLiLeiXing' />{{> #data}}</label></div>");
        $.map(this.fieldInstance.data.sub, function (e) {
                "linBaJieQinFan" === e.key ? (i.propItems.linBaJieQinFan = {
                    _self: e
                }, $.map(e.sub, function (e) {
                    i.propItems.linBaJieQinFan[e.key] = e
                })) : i.propItems[e.key] = e
            }), i.fieldInstance.layout.hideTitle || a.push("<div><span class='field-title'>" + this.fieldInstance.name + "</span></div>"), a.push("<table class='table table-bordered operation-table'><tbody>"), a.push(" <tr>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shouShuRiQi'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shouShuRiQi.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shouShuRiQi, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td colspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shouShuMingCheng'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shouShuMingCheng.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shouShuMingCheng, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shuZhe'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shuZhe.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shuZhe, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td colspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shiFouCanLiuZhongLiu'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shiFouCanLiuZhongLiu.name + "</label></div>"), a.push("         <div class='field-inline-control'>"),
            t(this.propItems.shiFouCanLiuZhongLiu, e), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".zhongLiuBuWei'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.zhongLiuBuWei.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(l.render(this.propItems.zhongLiuBuWei.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".fenHua'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.fenHua.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(o.render(this.propItems.fenHua.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".bingLiLeiXing'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.bingLiLeiXing.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(d.render(this.propItems.bingLiLeiXing.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".feiNeiZhuanYiZao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.feiNeiZhuanYiZao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.feiNeiZhuanYiZao, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".xiongShui'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.xiongShui.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.xiongShui, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".daXiao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.daXiao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.daXiao, e), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".zhongLiuDaXiao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.zhongLiuDaXiao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.zhongLiuDaXiao, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td colspan='3'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.linBaJieQinFan._self.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push("             <table class='table table-hover medi-compare' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#'>"), a.push("                 <thead>"), a.push("                     <th class='perm-edit' style='width:10px'></th>"), a.push("                     <th class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.zuShu'>组数</th>"), a.push("                     <th colspan='2' class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.fenZi'>淋巴结数</th>"), a.push("                     <th class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.fenMu'></th>"), a.push("                 </thead>"), a.push("                 <tbody data-bind='foreach: linBaJieQinFan'>"), a.push("                     <tr>"), a.push("                         <td class='td-del perm-edit'>"), a.push("                             <a href='javascript:void(0)' data-bind='click: $parent.removeItem' title='删除'>"), a.push("                             <span class='glyphicon glyphicon-remove'></span></a>"), a.push("                         </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.zuShu, e), a.push("                         </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.fenZi, e), a.push("                         </td>"), a.push("                         <td style='width:20px'> / </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.fenMu, e), a.push("                         </td>"), a.push("                 </tbody>"), a.push("                 <tfoot><tr>"), a.push("                     <td colspan='99' class='td-add perm-edit' style='text-align:left'><a href='javascript:void(0)' data-bind='click: addItem'>"), a.push("                         <span class='glyphicon glyphicon-plus'></span> 添加新项</a></td>"), a.push("                 </tr></tfoot>"), a.push("             </table>"), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push("</tbody></table>"), this.$container.html(a.join("")), i.$container.find("input.calendar").datepicker({
                todayBtn: "linked",
                format: "yyyy-mm-dd",
                language: "zh-CN",
                autoclose: !0
            }), this.koValue.addItem = function () {
                i.koValue().linBaJieQinFan.push({
                    zuShu: ko.observable(null),
                    fenZi: ko.observable(null),
                    fenMu: ko.observable(null)
                })
            }, this.koValue.removeItem = function (e) {
                i.koValue().linBaJieQinFan.remove(e)
            }
    }, mediForm.ctrls.OvarianCancerOperationCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.OvarianCancerOperationCtrl.base.getValue.call(this);
        return $.each(e.linBaJieQinFan, function (e, t) {
            "" !== t.zuShu && (t.zuShu = parseInt(t.zuShu)), "" !== t.fenZi && (t.fenZi = parseInt(t.fenZi)), "" !== t.fenMu && (t.fenMu = parseInt(t.fenMu))
        }), e
    }, mediForm.ctrls.OvarianCancerOperationCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.OvarianCancerOperationCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.PancreaticCancerOperationCtrl = function () {
        this.propItems = {}
    }, mediForm.ctrls.registerType("PancreaticCancerOperation", mediForm.ctrls.PancreaticCancerOperationCtrl), mediForm.ctrls.PancreaticCancerOperationCtrl.prototype.internalRender = function (e) {
        function t(e, t) {
            t ? a.push("<span class='field-value' data-bind='text: " + e.key + "'></span>") : $.isArray(e.options) ? (a.push("<select class='form-control' data-bind='value:" + e.key + "'>"), a.push("<option value=''>（请选择...）</option>"), a.push(s.render(e.options)), a.push("</select>")) : (a.push("<input type='text' class='form-control"), "date" === e.type && a.push(" calendar"), a.push("' data-bind='value: " + e.key + "' "), a.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), a.push(" />"))
        }
        var i = this,
            a = [],
            n = e ? " disabled='disabled'" : "",
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            l = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: zhongLiuBuWei' />{{> #data}}</label></div>"),
            o = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: fenHua' />{{> #data}}</label></div>"),
            d = $.templates("<div><label class='checkbox-inline'><input type='checkbox' value='{{attr: #data}}'" + n + " data-bind='checked: bingLiLeiXing' />{{> #data}}</label></div>");
        $.map(this.fieldInstance.data.sub, function (e) {
            "linBaJieQinFan" === e.key ? (i.propItems.linBaJieQinFan = {
                _self: e
            }, $.map(e.sub, function (e) {
                i.propItems.linBaJieQinFan[e.key] = e
            })) : i.propItems[e.key] = e
        }), i.fieldInstance.layout.hideTitle || a.push("<div><span class='field-title'>" + this.fieldInstance.name + "</span></div>"), a.push("<table class='table table-bordered operation-table'><tbody>"), a.push(" <tr>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shouShuRiQi'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shouShuRiQi.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shouShuRiQi, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td colspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shouShuMingCheng'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shouShuMingCheng.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shouShuMingCheng, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shuZhe'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shuZhe.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shuZhe, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shiFouCanLiuZhongLiu'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shiFouCanLiuZhongLiu.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shiFouCanLiuZhongLiu, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".shiFouGanZhuanYi'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.shiFouGanZhuanYi.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.shiFouGanZhuanYi, e), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".zhongLiuBuWei'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.zhongLiuBuWei.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(l.render(this.propItems.zhongLiuBuWei.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".fenHua'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.fenHua.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(o.render(this.propItems.fenHua.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td rowspan='2' class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".bingLiLeiXing'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.bingLiLeiXing.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push(d.render(this.propItems.bingLiLeiXing.options)), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".ganNeiZhuanYiZao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.ganNeiZhuanYiZao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.ganNeiZhuanYiZao, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".fuShui'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.fuShui.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.fuShui, e), a.push("         </div>"), a.push("     </td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + i.fieldInstance.key + ".daXiao'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.daXiao.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), t(this.propItems.daXiao, e), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr>"), a.push("     <td colspan='3'>"), a.push("         <div class='field-inline-label'><label class='control-label'>" + this.propItems.linBaJieQinFan._self.name + "</label></div>"), a.push("         <div class='field-inline-control'>"), a.push("             <table class='table table-hover medi-compare' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#'>"), a.push("                 <thead>"), a.push("                     <th class='perm-edit' style='width:10px'></th>"), a.push("                     <th class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.zuShu'>组数</th>"), a.push("                     <th colspan='2' class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.fenZi'>淋巴结数</th>"), a.push("                     <th class='medi-tip' data-path='" + i.fieldInstance.key + ".linBaJieQinFan#.fenMu'></th>"), a.push("                 </thead>"), a.push("                 <tbody data-bind='foreach: linBaJieQinFan'>"), a.push("                     <tr>"), a.push("                         <td class='td-del perm-edit'>"), a.push("                             <a href='javascript:void(0)' data-bind='click: $parent.removeItem' title='删除'>"), a.push("                             <span class='glyphicon glyphicon-remove'></span></a>"), a.push("                         </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.zuShu, e), a.push("                         </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.fenZi, e), a.push("                         </td>"), a.push("                         <td style='width:20px'> / </td>"), a.push("                         <td>"), t(this.propItems.linBaJieQinFan.fenMu, e), a.push("                         </td>"), a.push("                 </tbody>"), a.push("                 <tfoot><tr>"), a.push("                     <td colspan='99' class='td-add perm-edit' style='text-align:left'><a href='javascript:void(0)' data-bind='click: addItem'>"), a.push("                         <span class='glyphicon glyphicon-plus'></span> 添加新项</a></td>"), a.push("                 </tr></tfoot>"), a.push("             </table>"), a.push("         </div>"), a.push("     </td>"), a.push(" </tr>"), a.push("</tbody></table>"), this.$container.html(a.join("")), i.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), this.koValue.addItem = function () {
            i.koValue().linBaJieQinFan.push({
                zuShu: ko.observable(null),
                fenZi: ko.observable(null),
                fenMu: ko.observable(null)
            })
        }, this.koValue.removeItem = function (e) {
            i.koValue().linBaJieQinFan.remove(e)
        }
    }, mediForm.ctrls.PancreaticCancerOperationCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.PancreaticCancerOperationCtrl.base.getValue.call(this);
        return $.each(e.linBaJieQinFan, function (e, t) {
            "" !== t.zuShu && (t.zuShu = parseInt(t.zuShu)), "" !== t.fenZi && (t.fenZi = parseInt(t.fenZi)), "" !== t.fenMu && (t.fenMu = parseInt(t.fenMu))
        }), e
    }, mediForm.ctrls.PancreaticCancerOperationCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.PancreaticCancerOperationCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.PicCtrl = function () {}, mediForm.ctrls.registerType("Pic", mediForm.ctrls.PicCtrl), mediForm.ctrls.PicCtrl.prototype.internalRender = function (e) {
        function t() {
            c.delegate(".arrow-next", "click", function () {
                u < p.length - 1 ? (u++, o(p[u])) : (c.find(".photo_message_last").show(), setTimeout(function () {
                    c.find(".photo_message_last").hide()
                }, 1e3))
            }).delegate(".arrow-previous", "click", function () {
                u > 0 ? (u--, o(p[u])) : (c.find(".photo_message_first").show(), setTimeout(function () {
                    c.find(".photo_message_first").hide()
                }, 1e3))
            }).delegate(".photo_viewLarge", "click", function () {
                var e = p[u],
                    t = e.formResId ? e.formResId : I,
                    i = e.imgId.replace("_t.", ".");
                i = i.substring(0, i.indexOf("&")), g_form.centerId ? window.open("/Pages/ViewPhoto/" + g_form.centerId + "/" + t + "?img=" + encodeURIComponent(i)) : window.open("/Pages/ViewPhoto/" + g_form.diseaseId + "/" + t + "?img=" + encodeURIComponent(i))
            }).delegate(".noteSave", "click", function (e) {
                e.preventDefault();
                var t, i, a = f.koValue().result()[u],
                    n = c.find(".photo-taken-date"),
                    s = c.find(".tag-container > span.tag-single.active"),
                    l = [];
                if (s.length > 5) return alert("最多可选择 5 个标签"), !1;
                if (s.length > 0 && s.each(function () {
                        l.push($(this).text())
                    }), t = n.val() ? n.val() : null) {
                    var o = new Date(Date.parse(t.replace(/-/g, "/")));
                    if (o > new Date) return n.parent().addClass("has-error"), void n.next().show();
                    n.parent().removeClass("has-error"), n.next().hide()
                }
                i = c.find("textarea").val(), a.note(i), a.takenDate(t), a.tags(l), p[u].note = i, p[u].takenDate = t, p[u].tags = l, c.find(".modal-footer .note-date").text(p[u].takenDate ? p[u].takenDate : ""), c.find(".modal-footer .note-tags").html("");
                var r = p[u].tags;
                "object" != typeof r && (r = JSON.parse(r)), $.each(r, function (e, t) {
                    c.find(".modal-footer .note-tags").append("<span class='tag-single active'>" + t + "</span>")
                }), c.find(".noteAreaRead").text(p[u].note), d("disp"), c.find(".noteAreaEdit").show(), $.each(l, function (e, t) {
                    $.inArray(t, k) >= 0 && g_form.photoTag.push(t)
                })
            }).delegate(".noteAreaEdit", "click", function (t) {
                if (t.preventDefault(), !e) {
                    var i = p[u];
                    c.find("textarea").val(i.note), c.find("textarea").focus();
                    var a = c.find("textarea").val().length;
                    c.find("textarea")[0].setSelectionRange && c.find("textarea")[0].setSelectionRange(a, a), c.find(".modal-footer .photo-taken-date").val(i.takenDate ? i.takenDate : "").datepicker("update"), c.find(".tag-container").html(y.render(g_form.photoTag)), c.find(".modal-footer .note-created").hide();
                    var n = i.tags;
                    if ("object" != typeof i.tags && (n = JSON.parse(i.tags)), n && n.length > 0) {
                        var s = [];
                        $.each(n, function (e, t) {
                            c.find(".tag-container span[data-tag='" + t + "']").length > 0 && c.find(".tag-container span[data-tag='" + t + "']").remove(), s.push("<span data-tag='"), s.push(t), s.push("' class='tag-single active'>"), s.push(t), s.push("</span>")
                        }), c.find(".tag-container").prepend(s.join("")), c.find(".tags-more").removeClass("hidden"), c.find(".tag-container").removeClass("no-elm"), c.find(".add-tags-group").addClass("hidden")
                    }
                    d("edit")
                }
            }).delegate(".tags-more", "click", function (e) {
                e.preventDefault(), "更多" === $(this).find("a").text() ? ($(this).find("a").text("收起"), c.find(".tag-container").addClass("no-elm"), c.find(".add-tag-text").removeClass("hidden")) : ($(this).find("a").text("更多"), c.find(".add-tags-group").addClass("hidden"), c.find(".tag-container").removeClass("no-elm"), c.find(".add-tag-text").addClass("hidden"))
            }).delegate(".add-tag-text", "click", function (e) {
                e.preventDefault(), $(this).addClass("hidden"), c.find(".add-tags-group").removeClass("hidden"), c.find(".new-tag-input").focus()
            }).delegate(".tag-container span.tag-single", "click", function (e) {
                e.preventDefault(), s($(this))
            }).delegate(".new-tag-input", "keypress", function (e) {
                "13" == event.keyCode && (n(c), e.preventDefault())
            }).delegate(".new-tag-input", "blur", function (e) {
                $(this).val() && $(this).val().length > 10 ? (c.find(".add-tags-group").addClass("has-error"), c.find(".add-tags-group .text-info").show()) : (c.find(".add-tags-group").removeClass("has-error"), c.find(".add-tags-group .text-info").hide())
            }).delegate(".add-tags-group button", "click", function (e) {
                e.preventDefault(), n(c)
            })
        }

        function i() {
            h.on("show.bs.modal", function (e) {
                function t(e) {
                    return 10 > e ? "0" + e.toString() : e.toString()
                }
                var i = new Date;
                k = [], h.find(".photo-taken-date").val(i.getFullYear() + "-" + t(i.getMonth() + 1) + "-" + t(i.getDate())).datepicker("update"), h.find(".btn-upload").prop("disabled", !1), h.find(".progress").hide(), r(h)
            }), h.delegate(".tag-container span.tag-single", "click", function (e) {
                e.preventDefault(), s($(this))
            }).delegate(".tags-more", "click", function (e) {
                e.preventDefault(), "更多" === $(this).find("a").text() ? ($(this).find("a").text("收起"), h.find(".tag-container").addClass("no-elm"), h.find(".add-tag-text").removeClass("hidden")) : ($(this).find("a").text("更多"), h.find(".add-tags-group").addClass("hidden"), h.find(".tag-container").removeClass("no-elm"), h.find(".add-tag-text").addClass("hidden"))
            }).delegate(".add-tag-text", "click", function (e) {
                e.preventDefault(), $(this).addClass("hidden"), h.find(".add-tags-group").removeClass("hidden"), h.find(".new-tag-input").focus()
            }).delegate(".new-tag-input", "keypress", function (e) {
                "13" == event.keyCode && (n(h), e.preventDefault())
            }).delegate(".new-tag-input", "blur", function (e) {
                $(this).val() && $(this).val().length > 10 ? (h.find(".add-tags-group").addClass("has-error"), h.find(".add-tags-group .text-info").show()) : (h.find(".add-tags-group").removeClass("has-error"), h.find(".add-tags-group .text-info").hide())
            }).delegate(".add-tags-group button", "click", function (e) {
                e.preventDefault(), n(h)
            }).delegate(".btn-upload", "click", function (e) {
                function t(e, t) {
                    var i = new Date,
                        s = i.getTime() + "_" + e,
                        o = t.name.split(".").pop(),
                        r = s + "." + o,
                        c = s + "_t." + o;
                    return $.ajax({
                        url: "/api/Attachment?id=" + r + p + "&r=" + Math.random(),
                        type: "POST",
                        data: t,
                        cache: !1,
                        contentType: !1,
                        processData: !1
                    }).complete(function () {
                        d++, d === u && m.resolve()
                    }).done(function (e) {
                        h.find(".bar").width(parseInt(d / u * 100) + "%"), e.success && (v++, f.koValue().result.push({
                            id: 0,
                            imgId: "/api/Attachment?id=" + c + p,
                            note: ko.observable(h.find("textarea").val()),
                            tags: ko.observable(l),
                            takenDate: ko.observable(n.val()),
                            src: ""
                        }), a())
                    })
                }
                e.preventDefault();
                var i = $(this),
                    n = h.find(".photo-taken-date"),
                    s = h.find(".tag-container span.tag-single.active"),
                    l = [];
                if (s.length > 5) return alert("最多可选择 5 个标签"), !1;
                if (s.length > 0 && s.each(function () {
                        l.push($(this).text())
                    }), n.val()) {
                    var o = new Date(Date.parse(n.val().replace(/-/g, "/")));
                    if (o > new Date) return n.parent().addClass("has-error"), void n.next().show();
                    n.parent().removeClass("has-error"), n.next().hide()
                }
                var d = 0,
                    r = h.find(":file")[0].files,
                    u = r.length,
                    p = "&diseaseId=" + g_form.diseaseId + "&formResultId=" + I,
                    c = $.Deferred().resolve().promise(),
                    m = $.Deferred(),
                    v = 0;
                0 == r.length && h.modal("hide"), i.prop("disabled", !0), h.find(".progress").show(), $.each(r, function (e, i) {
                    c = c.then(function () {
                        return t(e, i)
                    })
                }), m.done(function () {
                    $.each(l, function (e, t) {
                        $.inArray(t, k) >= 0 && g_form.photoTag.push(t)
                    }), d > v && alert("部分图片上传失败，请重新选择"), i.prop("disabled", !1), h.find(".progress").hide(), h.find(".bar").width("0%"), h.modal("hide")
                })
            }), m.delegate(".img-border", "click", function () {
                $(this).toggleClass("selected"), m.find(".pkg-selected").text(m.find(".selected").length)
            }).delegate(".btn-done-select", "click", function (e) {
                e.preventDefault(), m.find(".selected").each(function () {
                    var e = g[$(this).data("idx")];
                    f.koValue().result.push({
                        id: 0,
                        imgId: e.url,
                        note: ko.observable(e.picNote),
                        tags: ko.observable(e.tags),
                        takenDate: ko.observable(e.takenDate),
                        src: "",
                        formResId: e.resultId
                    }), a()
                }), m.modal("hide")
            })
        }

        function a() {
            var e = $($(f.$container).find(".imgContainer"));
            e.each(function (e, t) {
                var i = Sortable.create(t, {
                    group: "photo" + e,
                    animation: 150,
                    draggable: ".gridly",
                    handle: ".gridly"
                });
                [].forEach.call(t.getElementsByClassName("gridly"), function (e) {
                    Sortable.create(e, {
                        onEnd: function (e) {
                            var t = e.oldIndex,
                                i = e.newIndex;
                            if (!isNaN(t) && !isNaN(i)) {
                                var a, n = ko.mapping.toJS(f.koValue().result);
                                if (t == i) return;
                                i > t ? (a = n[t], n.splice(t, 1), n.splice(i, 0, a)) : t > i && (a = n[t], n.splice(t, 1), n.splice(i, 0, a)), f.koValue().result(n)
                            }
                        }
                    })
                }), i.destroy()
            })
        }

        function n(e) {
            var t = e.find(".new-tag-input").val();
            return t = $.trim(t), t.length > 10 ? (e.find(".add-tags-group").addClass("has-error"), e.find(".add-tags-group .text-info").text("标签长度限定不超过10个字").show(), !1) : (e.find(".add-tags-group").removeClass("has-error"), e.find(".add-tags-group .text-info").hide(), 0 == t.length ? (e.find(".add-tags-group").addClass("has-error"), e.find(".add-tags-group .text-info").text("标签不能为空").show(), !1) : $.inArray(t, g_form.photoTag) >= 0 || $.inArray(t, k) >= 0 ? (e.find(".add-tags-group").addClass("has-error"), e.find(".add-tags-group .text-info").text("此标签已存在").show(), !1) : (e.find(".add-tags-group").removeClass("has-error"), e.find(".add-tags-group .text-info").hide(), k.push(t), e.find(".tag-container span.tag-single.active").length < 5 ? e.find(".tag-container").append("<span data-tag='" + t + "' class='tag-single active'>" + t + "</span>") : e.find(".tag-container").append("<span data-tag='" + t + "' class='tag-single'>" + t + "</span>"), e.find(".new-tag-input").val(""), void e.find(".tag-body > .tag-container").scrollTop(99999)))
        }

        function s(e) {
            if (e.hasClass("active")) e.removeClass("active");
            else {
                if (e.siblings(".active").length >= 5) return alert("最多可选择 5 个标签"), !1;
                e.addClass("active")
            }
        }

        function l(e) {
            if (!e) return e;
            var t = e.indexOf("T");
            return 0 > t ? e : e.substr(0, t)
        }

        function o(t) {
            k = [], e || c.find(".noteAreaEdit").show(), c.find(".modal-body img").removeAttr("src"), c.find(".modal-body img").attr("src", t.imgId.replace("_t.", ".")), c.find(".modal-footer .noteAreaRead").text(t.note), c.find(".modal-footer .note-date").text(t.takenDate ? t.takenDate : ""), c.find(".modal-footer .note-tags").html("");
            var i = t.tags;
            "object" != typeof i && (i = JSON.parse(i)), $.each(i, function (e, t) {
                c.find(".modal-footer .note-tags").append("<span class='tag-single active'>" + t + "</span>")
            }), d("disp"), r(c)
        }

        function d(e) {
            "disp" == e ? (c.find(".noteAreaRead").show(), c.find(".noteDate-tags").show(), c.find(".noteAreaDiv").hide()) : (c.find(".noteAreaRead, .noteDate-tags, .noteAreaEdit").hide(), c.find(".noteAreaDiv").show())
        }

        function r(e) {
            e.find(".tag-container span.tag-single").removeClass("active"), e.find(".add-tags-group, .add-tag-text").addClass("hidden"), e.find(".add-tags-group").removeClass("has-error"), e.find(".photo-taken-date").parent().removeClass("has-error"), e.find(".text-info").hide(), e.find(".new-tag-input").val(""), e.find(".tags-more > a").text("更多"), e.find(".tag-container").html(y.render(g_form.photoTag)), g_form.photoTag.length <= 0 ? (e.find(".tags-more").addClass("hidden"), e.find(".tag-container").addClass("no-elm"), e.find(".add-tags-group").removeClass("hidden")) : (e.find(".tags-more").removeClass("hidden"), e.find(".tag-container").removeClass("no-elm"), e.find(".add-tags-group").addClass("hidden"))
        }
        var u, p, c, h, m, f = this,
            v = [],
            g = null,
            b = $.templates("<div class='img-border' data-idx='{{:#index}}'><img width='184' src='{{attr: url}}' /><div class='img-btn-note'>{{if takenDate}}{{:takenDate}}{{else}}''{{/if}}</div><div class='marker'><span class='glyphicon glyphicon-ok'></span></div></div>"),
            y = $.templates("<span data-tag='{{:#data}}' class='tag-single'>{{:#data}}</span>"),
            k = [],
            I = g_form.resultId ? g_form.resultId : g_form.newId;
        f.fieldInstance.layout.hideTitle || v.push("<div><label class='control-label'>" + f.fieldInstance.name + "</label></div>"), v.push("<div class='imgContainer'>"), v.push(" <div class='gridly' data-bind='foreach: result'>"), v.push("     <div class='img-border'>"), v.push("         <img width='184' data-bind='click: $parent.zoomItem, attr:{src:imgId}'  />"), e || v.push("     <div class='img-btn-delete' data-bind='click: $parent.removeItem'><button type='button' class='close' aria-hidden='true' style='padding: 1px 6px 0 0;'>×</button></div>"), v.push("<div class='img-btn-note' data-bind='text:takenDate'></div>"), v.push(" </div>"), v.push("</div>"), e || (f.fieldInstance.config.allowExternal ? (v.push("<div class='field-edit img-btn-container'>"), v.push("     <div class='add-sign'><span class='glyphicon glyphicon-plus'></span></div>"), v.push("     <button class='btn btn-default btn-block' data-bind='click: addItem'><span class='glyphicon glyphicon-open'></span>&nbsp;本地上传</button>"), v.push("     <button class='btn btn-default btn-block' data-bind='click: selectItem'><span class='glyphicon glyphicon-picture'></span>&nbsp;影像资料</button>"), v.push("</div>")) : v.push("<div class='field-edit action-addphoto img-btn-add' data-bind='click: addItem'><span class='glyphicon glyphicon-plus'></span></div>")), v.push("</div>"), v.push("<div class='modal-view modal fade' tabindex='-1' role='dialog' aria-hidden='true'>"), v.push(" <div class='box'>"), v.push("    <div class='modal-dialog' style='width:1000px;'>"), v.push("        <div class='modal-content'>"), v.push("            <div class='modal-body view_picture'>"), v.push("                <div class='form-horizontal text-center'>"), v.push("                     <div class='arrow-next'></div>"), v.push("                     <div class='arrow-previous'></div>"), v.push('                     <div class="photo_rotate"style="display:none;"><span class="glyphicon glyphicon-repeat" style="transform:scaleX(1)"></span></div>'), v.push("                     <div class='photo_viewLarge'>查看原图</div>"), v.push("                     <div class='photo_message_first'>已到第一张</div>"), v.push("                     <div class='photo_message_last'>已到最后一张</div>"), v.push("                     <img style='max-width: 662px;max-height: 914px;margin: 45px 15px;' src='/content/img/loading.gif' />"), v.push("                </div>"), v.push("            <div class='information modal-footer' style='text-align:left'>"), v.push("                <div class='noteDate-tags form-group' style='margin-bottom: 10px;'>"), v.push("                    <label class='note-date'></label>"), v.push("                    <div class='note-tags col-sm-12'></div>"), v.push("                    <div class='noteAreaRead'></div>"), v.push("                    <div class='note-created pull-right'></div>"), v.push("                    <div class='noteAreaEdit btn btn-success col-sm-1' style='display:none'>编辑</div>"), v.push("                </div>"), v.push("                <div class='noteAreaDiv form-group' style='margin-top: 5px'>"), v.push("                    <div class='form-group row'>"), v.push("                        <label class=''>拍摄日期</label>"), v.push("                        <div class=''>"), v.push("                            <input class='form-control calendar photo-taken-date' type='text' value='' />"), v.push("                            <div class='text-info fa' style='display:none;'> 拍摄日期不应晚于今日</div>"), v.push("                        </div>"), v.push("                    </div>"), v.push("                    <div class='form-group row tags'>"), v.push("                    <label class=''>标     签</label>"), v.push("                        <div class=''>"), v.push("                            <div class='tag-body'>"), v.push("                                <div class='tag-container'></div>"), v.push("                                <div class='add-tag-text hidden pull-left'><a href='javascript:void(0)'>添加新标签</a></div>"), v.push("                            </div>"), v.push("                            <div class='tags-more'><a href='javascript:void(0)'>更多</a></div>"), v.push("                            <div class='add-tags-group hidden'>"), v.push("                                <div class='input-group'>"), v.push("                                    <input type='text' class='form-control new-tag-input' placeholder='添加新标签' />"), v.push("                                    <span class='input-group-btn'>"), v.push("                                        <button class='btn btn-default' type='button'>添加</button>"), v.push("                                    </span>"), v.push("                                </div>"), v.push("                                <div class='text-info fa' style='display:none'> 标签长度限定不超过10个字</div>"), v.push("                            </div>"), v.push("                        </div>"), v.push("                    </div>"), v.push("                    <div class='form-group row'>"), v.push("                        <label class=''>照片描述</label>"), v.push("                        <div class=''>"), v.push("                                <textarea class='form-control noteArea' style='display:inline;' rows='3'></textarea>"), v.push("                        </div>"), v.push("                    </div>"), v.push("                     <div style='float:right'>"), v.push("                         <button class='noteSave btn btn-success'>保存</button>"), v.push("                     </div>"), v.push("                 </div>"), v.push("              </div>"), v.push("            </div>"), v.push('         <div class="close_pic" data-dismiss="modal" aria-hidden="true"><img src="/Content/Images/Close_Pictures.png"></div>'), v.push("        </div>"), v.push("    </div>"), v.push(" </div>"), v.push("</div>"), e || (v.push("<div class='modal-upload modal fade' tabindex='-1' role='dialog' aria-hidden='true' data-backdrop='static'>"), v.push(" <div class='box'>"), v.push("    <div class='modal-dialog'>"), v.push("        <div class='modal-content'style='width: 508px;'>"), v.push("            <div class='modal-header'>"), v.push("                 上传照片"), v.push("                 <div  class='close' data-dismiss='modal' aria-hidden='true'>关闭</div>"),
            v.push("            </div>"), v.push("            <div class='modal-body'>"), v.push("                <div class='form-horizontal'>"), v.push("                    <div class='form-group'>"), v.push("                        <label class='addPhoto_text'>选择图片</label>"), v.push("                        <div class='col-sm-10'style='width:392px'>"), v.push("                            <input type='file' class='file' data-allowed-file-types='[\"image\"]' data-show-upload='false' data-show-preview='false' multiple='true' accept='image/jpg,image/jpeg,image/png,image/bmp,image/gif' />"), v.push("                        </div>"), v.push("                    </div>"), v.push("                    <div class='progress progress-striped' style='width: 452px; margin-left:10px; height: 15px; display:none'>"), v.push("                        <div class='bar progress-bar progress-bar-striped active' style='width: 0%; height: 15px;'>&nbsp;</div>"), v.push("                    </div>"), v.push("                    <div class='form-group row'>"), v.push("                        <label class='addPhoto_text'>拍摄日期</label>"), v.push("                        <div class='col-sm-10'style='width:362px;'>"), v.push("                            <input class='form-control calendar photo-taken-date' type='text' value='' />"), v.push("                            <div class='text-info fa' style='display:none;'> 拍摄日期不应晚于今日</div>"), v.push("                        </div>"), v.push("                    </div>"), v.push("                    <div class='form-group row tags'>"), v.push("                    <label class='addPhoto_text'>标签</label>"), v.push("                        <div class='col-sm-10'style='width:392px;'>"), v.push("                            <div class='tag-body'>"), v.push("                                <div class='tag-container'></div>"), v.push("                                <div class='add-tag-text hidden pull-left'><a href='javascript:void(0)'>添加新标签</a></div>"), v.push("                            </div>"), v.push("                            <div class='tags-more'><a href='javascript:void(0)'>更多</a></div>"), v.push("                            <div class='add-tags-group hidden'>"), v.push("                                <div class='input-group'>"), v.push("                                    <input type='text' class='form-control new-tag-input' placeholder='添加新标签' />"), v.push("                                    <span class='input-group-btn'>"), v.push("                                        <button class='btn btn-default' type='button'>添加</button>"), v.push("                                    </span>"), v.push("                                </div>"), v.push("                                <div class='text-info fa' style='display:none'> 标签长度限定不超过10个字</div>"), v.push("                            </div>"), v.push("                        </div>"), v.push("                    </div>"), v.push("                    <div class='form-group row'>"), v.push("                        <label class='addPhoto_text'>照片描述</label>"), v.push("                        <div class='col-sm-10'style='width:392px;'>"), v.push("                                <textarea class='form-control disable-in-process' style='display:inline;' rows='5' placeholder='描述信息'></textarea>"), v.push("                        </div>"), v.push("                    </div>"), v.push("                </div>"), v.push("            </div>"), v.push("            <div class='modal-footer'>"), v.push("                <button type='button' class='btn btn-upload btn-primary'>上传</button>"), v.push("            </div>"), v.push("        </div>"), v.push("    </div>"), v.push(" </div>"), v.push("</div>"), v.push("<div class='modal-select modal fade' tabindex='-1' role='dialog' aria-hidden='true' data-backdrop='static'>"), v.push(" <div class='box'>"), v.push("    <div class='modal-dialog modal-lg'>"), v.push("        <div class='modal-content'>"), v.push("            <div class='modal-header'>"), v.push("                <button type='button' class='close' data-dismiss='modal' aria-hidden='true'>关闭</button>"), v.push("                <div style=''>"), v.push("                    <h4 class='modal-title'>选取照片（<span class='pkg-selected'></span> / <span class='pkg-total'></span>）</h4>"), v.push("                </div>"), v.push("            </div>"), v.push("            <div class='modal-body'>"), v.push("                <div class='pkgImgContainer'></div>"), v.push("            </div>"), v.push("            <div class='modal-footer'>"), v.push("                <button type='button' class='btn btn-done-select btn-primary' style='margin-right: 15px;'>确定</button>"), v.push("            </div>"), v.push("        </div>"), v.push("    </div>"), v.push(" </div>"), v.push("</div>")), f.$container.addClass("medi-tip medi-compare medi-metadata-only").attr("data-path", f.fieldInstance.key).html(v.join("")), c = f.$container.find(".modal-view"), h = f.$container.find(".modal-upload"), m = f.$container.find(".modal-select"), f.$container.html(v.join("")), c = f.$container.find(".modal-view"), h = f.$container.find(".modal-upload"), m = f.$container.find(".modal-select"), t(), e || (i(), setTimeout(function () {
            a()
        }, 200)), f.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), f.koValue.zoomItem = function (e) {
            u = f.koValue().result.indexOf(e), p = ko.mapping.toJS(f.koValue().result);
            var t = $($(f.$container).find(".imgContainer .img-border")[u]);
            t.find("img").hasClass("moved") || (o(p[u]), c.modal("show"))
        }, f.koValue.addItem = function () {
            h.find(":file").fileinput("clear"), h.find("textarea").val(""), h.modal("show")
        }, f.koValue.selectItem = function () {
            m.modal("show"), g_form.mainId && (g ? (m.find(".selected").removeClass("selected"), m.find(".pkg-selected").text("0")) : $.getJSON("/api/Photo/" + g_form.diseaseId + "?formId=" + g_form.mainId + "&isMain=true").done(function (e) {
                e.success && (e.result.length <= 0 ? (m.find(".pkgImgContainer").html("<div class='text-center' style='margin-top:30px;'>影像资料中暂无照片</div>"), m.find(".pkg-total").text("0"), m.find(".pkg-selected").text("0")) : (g = [], $.each(e.result, function (e, t) {
                    t.takenDate = l(t.takenDate), t.resultId !== g_form.resultId && g.push(t)
                }), mediForm.util.initImgsUrl(g, g_form.diseaseId), m.find(".pkgImgContainer").html(b.render(g)), m.find(".pkg-total").text(g.length), m.find(".pkg-selected").text("0")))
            }))
        }, f.koValue.removeItem = function (e) {
            confirm("确定删除该图片吗？") && f.koValue().result.remove(e)
        }
    }, mediForm.ctrls.PicCtrl.prototype.getDefaultValue = function () {
        return {
            result: []
        }
    }, mediForm.ctrls.PicCtrl.prototype.getValue = function () {
        var e = ko.mapping.toJS(this.koValue).result;
        return e = $.map(e, function (e, t) {
            return e.imgId = e.imgId.substring(e.imgId.indexOf("?id=") + 4, e.imgId.indexOf("&")).replace("_t.", "."), e
        })
    }, mediForm.ctrls.PicCtrl.prototype.setValue = function (e) {
        function t(e) {
            var t = e.split(".");
            return t = $.map(t, function (e, i) {
                return i == t.length - 2 ? e + "_t" : e
            }), t.join(".")
        }
        var i;
        i = g_form.centerId ? "&centerId=" + g_form.centerId + "&diseaseId=" + g_form.diseaseId + "&deptId=" + g_form.deptId : "&diseaseId=" + g_form.diseaseId, e = $.map(e, function (e, a) {
            return e.imgId = "/api/Attachment?id=" + t(e.imgId) + "&formResultId=" + (e.formResId ? e.formResId : g_form.resultId) + i, e.takenDate || (e.takenDate = null), e.tags || (e.tags = []), e
        }), mediForm.ctrls.PicCtrl.base.setValue.call(this, {
            result: e
        })
    }, mediForm.ctrls.PlaceholderPicCtrl = function () {
        this.hasNoValue = !0
    }, mediForm.ctrls.registerType("PlaceholderPic", mediForm.ctrls.PlaceholderPicCtrl), mediForm.ctrls.PlaceholderPicCtrl.prototype.internalRender = function (e) {
        this.$container.html("<div class='PlaceholderPic'><div class='placeholderText'>" + this.fieldInstance.name + "</div><img src='" + g_blobFormPics + "/" + this.fieldInstance.config.picPath + "'/></div>"), this.$container.parent().addClass("PlaceholderPic")
    }, mediForm.ctrls.PlaceholderTextCtrl = function () {
        this.hasNoValue = !0
    }, mediForm.ctrls.registerType("PlaceholderText", mediForm.ctrls.PlaceholderTextCtrl), mediForm.ctrls.PlaceholderTextCtrl.prototype.internalRender = function (e) {
        this.$container.html("<div class='PlaceholderText'>" + this.fieldInstance.name + "</div>")
    }, mediForm.ctrls.PlaceholderTitleCtrl = function () {
        this.hasNoValue = !0
    }, mediForm.ctrls.registerType("PlaceholderTitle", mediForm.ctrls.PlaceholderTitleCtrl), mediForm.ctrls.PlaceholderTitleCtrl.prototype.internalRender = function (e) {
        this.$container.html("<div class='placeholderTitle'>" + this.fieldInstance.name + "</div>"), this.$container.parent().addClass("placeholderTitle")
    }, mediForm.ctrls.RadioButtonListCtrl = function () {}, mediForm.ctrls.registerType("RadioButtonList", mediForm.ctrls.RadioButtonListCtrl), mediForm.ctrls.RadioButtonListCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = this.fieldInstance.config.width ? this.fieldInstance.config.width : "100px",
            n = $.templates("<label class='radio-inline' style='width:" + a + ";'><input type='radio' name='" + t.fieldInstance.key + "' value='{{attr: #data}}' data-bind='checked: value' />{{> #data}}</label>"),
            s = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (s = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + s + " radioList'" + (e ? ">" : " style='padding-top:7px'>")), e ? i.push("<span class='field-value' data-bind='text: value'></span>") : i.push(n.render(mediForm.util.getEffectiveOptions(t.fieldInstance.config))), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join("")), t.$container.delegate(".radio-inline", "dblclick", function (e) {
            e.preventDefault(), t.setValue("")
        })
    }, mediForm.ctrls.RadioButtonListCtrl.prototype.getDefaultValue = function () {
        return {
            value: this.fieldInstance.config["default"] || ""
        }
    }, mediForm.ctrls.RadioButtonListCtrl.prototype.notifyAlways = function (e) {
        this.koValue().value.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.RadioButtonListCtrl.prototype.setOptions = function (e) {
        var t = this.getValue(),
            i = !0,
            a = mediForm.util.getEffectiveOptions(this.fieldInstance.config),
            n = e.filter(function (e) {
                return a.indexOf(e) > -1
            }),
            s = n.length;
        return this.$container.find(".field-value").length > 0 ? s : (this.$container.find(".radioList").children().each(function () {
            var a = $(this),
                n = a.find("input").val(),
                s = e.indexOf(n) < 0;
            s || n !== t || (i = !1), s ? a.hide() : a.show()
        }), i && this.setValue(null), s)
    }, mediForm.ctrls.RadioButtonListVTCtrl = function () {}, mediForm.ctrls.registerType("RadioButtonListVT", mediForm.ctrls.RadioButtonListVTCtrl), mediForm.ctrls.RadioButtonListVTCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = this.fieldInstance.config.width ? this.fieldInstance.config.width : "100px",
            n = $.templates("<label class='radio-inline' style='width:" + a + ";'><input type='radio' name='" + t.fieldInstance.key + "' value='{{attr: value}}' data-bind='checked: value' />{{> text}}</label>"),
            s = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (s = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + s + " radioList'" + (e ? ">" : " style='padding-top:7px'>")), e ? i.push("<span class='field-value-span' data-bind='text: value'></span>") : i.push(n.render(this.fieldInstance.config.options)), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join("")), t.fieldInstance.config.showTextInsteadOfValue && t.koValue.value.subscribe(function (e) {
            var i = "";
            $.each(t.fieldInstance.config.options, function (t, a) {
                return a.value == e ? (i = a.text, !1) : void 0
            }), t.$container.find(".field-value-span").text(i)
        }), t.$container.delegate(".radio-inline", "dblclick", function (e) {
            e.preventDefault(), t.setValue("")
        })
    }, mediForm.ctrls.RadioButtonListVTCtrl.prototype.getDefaultValue = function () {
        return {
            value: this.fieldInstance.config["default"] || ""
        }
    }, mediForm.ctrls.RadioButtonListVTCtrl.prototype.setValue = function (e) {
        if (mediForm.ctrls.RadioButtonListVTCtrl.base.setValue.call(this, e), this.fieldInstance.config.showTextInsteadOfValue && e) {
            var t = "";
            $.each(this.fieldInstance.config.options, function (i, a) {
                return a.value == e ? (t = a.text, !1) : void 0
            }), this.$container.find(".field-value-span").text(t)
        }
    }, mediForm.ctrls.RadioButtonListVTCtrl.prototype.notifyAlways = function (e) {
        this.koValue().value.extend({
            notify: e ? "always" : "none"
        })
    }, mediForm.ctrls.RepeatTableCtrl = function () {
        this.dispItems = [], this.optionsMap = {}
    }, mediForm.ctrls.registerType("RepeatTable", mediForm.ctrls.RepeatTableCtrl), mediForm.ctrls.RepeatTableCtrl.prototype.internalRender = function (e) {
        function t() {
            s.$container.find(".repeatTable-table > tbody > tr:last input.calendar").datepicker({
                todayBtn: "linked",
                format: "yyyy-mm-dd",
                language: "zh-CN",
                autoclose: !0
            }), s.$container.find(".repeatTable-table > tbody > tr:last button.dropdown-toggle").dropdown(), s.$container.find(".repeatTable-table > tbody > tr:last .selectpicker").selectpicker({
                liveSearch: !0,
                noneResultsText: "无相关数据",
                width: "auto",
                size: 10
            }).selectpicker("refresh"), window.setTimeout(function () {
                s.$container.find(".repeatTable-table > tbody > tr:last textarea.auto-sizable").each(function () {
                    mediForm.util.autoSizeTextarea(this, 1, 9)
                })
            }, 0)
        }

        function i(t) {
            var i = e ? "min-width" : "width";
            if (t.options && !t.allowFill && !t.subtype) return "";
            if (t.width) return " style='" + i + ":" + t.width + "'";
            if (t.allowFill) return "";
            if (t.subtype) return " style='" + i + ":150px'";
            switch (t.type) {
                case "integer":
                case "float":
                    return " style='" + i + ":80px'";
                case "date":
                    return " style='" + i + ":120px'";
                case "textarea":
                case "rich":
                    return " style='" + i + ":400px'";
                default:
                    return " style='" + i + ":100px'"
            }
        }

        function a(e) {
            return $.isArray(e.options) || e.optionsConfig ? e.allowFill || e.subtype ? ".input-group" : "select" : "input"
        }

        function n(e) {
            var t = e.skipInput ? " skip-input" : "";
            $.isArray(e.options) || e.optionsConfig ? e.allowFill ? (l.push("<div class='input-group dropdown combo" + t + "'>"), l.push(" <input type='text' class='form-control'" + i(e) + " data-bind='value: " + e.key + "' />"), l.push(" <div class='input-group-btn'>"), l.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), l.push("         <span class='caret'></span>"), l.push("     </button>"), l.push("     <ul class='dropdown-menu pull-right' role='menu'>"), l.push(s.optionsMap[e.key]), l.push("     </ul>"), l.push(" </div>"), l.push("</div>")) : e.subtype ? (l.push("<div class='input-group dropdown checkList" + t + "'>"), l.push(" <input type='text' class='form-control' " + i(e) + " data-bind='value: " + e.key + "' readonly='readonly' />"), l.push(" <div class='input-group-btn'>"), l.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), l.push("         <span class='caret'></span>"), l.push("     </button>"), l.push("     <ul class='dropdown-menu pull-right' role='menu'>"), l.push(s.optionsMap[e.key]), l.push("     </ul>"), l.push(" </div>"), l.push("</div>")) : (l.push("<select class='form-control" + t), e.search && l.push(" selectpicker"), l.push("'"), l.push(" data-bind='value:" + e.key + "'>"), l.push("<option value=''>（请选择...）</option>"), l.push(s.optionsMap[e.key]), l.push("</select>")) : "rich" === e.type ? l.push("<div class='froala-editor" + t + "' " + i(e) + " data-bind='froala: " + e.key + "'></div>") : "textarea" === e.type ? (l.push("<textarea class='form-control auto-sizable" + t + "' rows='1' data-bind='value: " + e.key + "' "), l.push(i(e) + "></textarea>")) : (l.push("<input type='text' class='form-control" + t), "date" === e.type && l.push(" calendar"), l.push("' data-bind='value: " + e.key + "' "), l.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern) + " "), o && l.push(i(e)), l.push(" />"))
        }
        var s = this,
            l = [],
            o = s.fieldInstance.config && s.fieldInstance.config.isComplex,
            d = s.fieldInstance.config && s.fieldInstance.config.hasCopy,
            r = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            u = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>"),
            p = $.templates("<li role='presentation' data-value='{{attr: option}}' data-bind='mediCheckList: {{:key}}'><a role='menuitem' tabindex='-1' href='#'><span class='fa fa-fw'></span> {{> option}}</a></li>");
        this.dispItems = [], $.map(s.fieldInstance.data.sub, function (e) {
            if (s.dispItems.push(e), e.optionsConfig || $.isArray(e.options))
                if (e.allowFill) s.optionsMap[e.key] = u.render(mediForm.util.getEffectiveOptions(e));
                else if (e.subtype) {
                var t = $.map(mediForm.util.getEffectiveOptions(e), function (t) {
                    return {
                        key: e.key,
                        option: t
                    }
                });
                s.optionsMap[e.key] = p.render(t)
            } else s.optionsMap[e.key] = r.render(mediForm.util.getEffectiveOptions(e))
        }), s.fieldInstance.layout.hideTitle || l.push("<div><span class='field-title'>" + s.fieldInstance.name + "</span></div>"), l.push("<table class='table table-hover repeatTable-table medi-compare' data-path='" + s.fieldInstance.key + "#'>"), o || (l.push("<thead><tr>"), e || l.push("<th class='td-del perm-edit'>&nbsp;</th>"), $.map(s.dispItems, function (e) {
            l.push("<th class='medi-tip' data-path='" + s.fieldInstance.key + "#." + e.key + (e.subtype ? "#" : "") + "'>" + e.name + "</th>")
        }), l.push("</tr></thead>")), l.push("<tbody data-bind='foreach: result'>"), l.push("<tr>"), e || (l.push("<td class='td-del perm-edit'><a href='javascript:void(0)' data-bind='click: $parent.removeItem' title='删除'>"), l.push("<span class='glyphicon glyphicon-remove'></span></a></td>")), o ? (l.push("<td class='field-inline-control-noTitle form-inline has-group simple-object'>"), $.map(this.dispItems, function (t) {
            var o = "rich" === t.type ? "html" : "text";
            t.newLine && l.push("<div></div>"), l.push("<div class='form-group medi-tip' data-path='" + s.fieldInstance.key + "#." + t.key + (t.subtype ? "#" : "") + "' data-subkey='" + t.key + "' data-ctrl='" + a(t) + "'>"), l.push("    <div class='input-group'>"), l.push("        <div class='input-group-addon'>" + t.name + "</div>"), e ? l.push("<div class='form-control field-value " + (t.subtype || t.type) + "'" + i(t) + " data-bind='" + o + ": " + t.key + "'></div>") : t.readonly ? l.push("<div class='form-control field-value field-readonly " + (t.subtype || t.type) + "'" + i(t) + " data-bind='" + o + ": " + t.key + "'></div>") : n(t), l.push("    </div>"), l.push("    <div class='error-msg' data-bind='validationMessage: " + t.key + "'></div>"), l.push("</div>")
        }), l.push("</td>")) : $.map(this.dispItems, function (t) {
            var i = "rich" === t.type ? "html" : "text";
            l.push("<td data-subkey='" + t.key + "' data-ctrl='" + a(t) + "'>"), e || t.readonly ? l.push("<span class='field-value " + (t.subtype || t.type) + "' data-bind='" + i + ":" + t.key + "'></span>") : n(t), l.push("</td>")
        }), l.push("</tr>"), l.push("</tbody>"), e || (l.push("<tfoot><tr>"), l.push("<td colspan='99' class='td-add perm-edit' style='text-align:left'>"), l.push("     <a href='javascript:void(0)' data-bind='click: addItem'>"), l.push("         <span class='glyphicon glyphicon-plus'></span> 添加新项</a>"), d && (l.push("     <a href='javascript:void(0)' data-bind='click: copyLast, visible: result().length>0' style='margin-left:30px;'>"), l.push("         <span class='glyphicon glyphicon-duplicate'></span> 复制末项</a>")), l.push("</td>"), l.push("</tr></tfoot>")), l.push("</table>"), s.$container.html(l.join("")), s.$container.delegate("textarea.auto-sizable", "keyup", $.debounce(200, !1, function () {
            mediForm.util.autoSizeTextarea(this, 1, 9)
        })).delegate("div.dropdown", "shown.bs.dropdown", function () {
            $(this).find("ul.dropdown-menu").outerWidth($(this).outerWidth())
        }).delegate(".combo ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), $(this).parents(".dropdown:eq(0)").children("input").val($(this).text()).trigger("change")
        }), s.$container.delegate(".checkList ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), e.stopPropagation()
        }), s.koValue.addItem = function () {
            s.koValue().result.push(s.getSingleEmptyItem()), t()
        }, s.koValue.removeItem = function (e) {
            s.koValue().result.remove(e)
        }, d && (s.koValue.copyLast = function () {
            s.koValue().result.push(s.copyLastItem()), t()
        })
    }, mediForm.ctrls.RepeatTableCtrl.prototype.getDefaultValue = function () {
        return {
            result: []
        }
    }, mediForm.ctrls.RepeatTableCtrl.prototype.getSingleEmptyItem = function () {
        var e = {};
        return $.map(this.dispItems, function (t) {
            e[t.key] = t.subtype ? ko.observableArray([]) : ko.observable(null)
        }), e
    }, mediForm.ctrls.RepeatTableCtrl.prototype.copyLastItem = function () {
        var e, t = this.koValue().result(),
            i = {};
        return delete t[t.length - 1]._$row, e = ko.mapping.toJS(t[t.length - 1]), $.map(this.dispItems, function (t) {
            i[t.key] = t.subtype ? ko.observableArray(e[t.key]) : ko.observable(e[t.key])
        }), i
    }, mediForm.ctrls.RepeatTableCtrl.prototype.setValue = function (e) {
        var t = this;
        this.correctValue(e), e && e.length > 0 && mediForm.ctrls.RepeatTableCtrl.base.setValue.call(this, {
            result: []
        }), mediForm.ctrls.RepeatTableCtrl.base.setValue.call(this, {
            result: e
        }), this.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), this.$container.find("button.dropdown-toggle").dropdown(), window.setTimeout(function () {
            t.$container.find("textarea.auto-sizable").each(function () {
                mediForm.util.autoSizeTextarea(this, 1, 9)
            })
        }, 0)
    }, mediForm.ctrls.RepeatTableCtrl.prototype.getValue = function () {
        var e, t = this;
        return this.koValue().result().forEach(function (e) {
            delete e._$row
        }), e = mediForm.ctrls.RepeatTableCtrl.base.getValue.call(this).result, this.bindRow(), $.map(e, function (e) {
            $.map(t.dispItems, function (t) {
                t.subtype && !e[t.key] && (e[t.key] = []), t.subtype || "" !== $.trim(e[t.key]) || (e[t.key] = null), null === e[t.key] || "integer" !== t.type && "float" !== t.type || (e[t.key] = parseFloat(e[t.key]))
            })
        }), e
    }, mediForm.ctrls.RepeatTableCtrl.prototype.bindRow = function () {
        var e = this.koValue().result();
        this.$container.find(".repeatTable-table > tbody > tr").each(function (t) {
            e[t]._$row = $(this)
        })
    }, mediForm.ctrls.RepeatTableCtrl.prototype.hideSubItem = function (e, t) {
        var i, a = this.fieldInstance.config && this.fieldInstance.config.isComplex,
            n = t._$row;
        a ? (i = n.find(".simple-object").children(".form-group[data-subkey='" + e + "']"), i.hide()) : (i = n.children("td[data-subkey='" + e + "']"), i.children(i.data("ctrl")).hide())
    }, mediForm.ctrls.RepeatTableCtrl.prototype.showSubItem = function (e, t) {
        var i, a = this.fieldInstance.config && this.fieldInstance.config.isComplex,
            n = t._$row;
        a ? (i = n.find(".simple-object").children(".form-group[data-subkey='" + e + "']"), i.show()) : (i = n.children("td[data-subkey='" + e + "']"), i.children(i.data("ctrl")).show())
    }, mediForm.ctrls.RepeatTableCtrl.prototype.disableSubItem = function (e, t) {
        var i, a = this.fieldInstance.config && this.fieldInstance.config.isComplex,
            n = t._$row;
        i = a ? n.find(".simple-object").children(".form-group[data-subkey='" + e + "']") : n.children("td[data-subkey='" + e + "']"), i.find("input, textarea, select, button").prop("disabled", !0)
    }, mediForm.ctrls.RepeatTableCtrl.prototype.enableSubItem = function (e, t) {
        var i, a = this.fieldInstance.config && this.fieldInstance.config.isComplex,
            n = t._$row;
        i = a ? n.find(".simple-object").children(".form-group[data-subkey='" + e + "']") : n.children("td[data-subkey='" + e + "']"), i.find("input, textarea, select, button").prop("disabled", !1)
    }, mediForm.ctrls.RepeatTableCtrl.prototype.setOptions = function (e, t, i) {
        function a(a) {
            var n = !1,
                s = "";
            r.find("ul.dropdown-menu").children().each(function () {
                var e = $(this),
                    i = e.find("a").text(),
                    a = "none" === e.css("display"),
                    l = t.indexOf(i) < 0;
                a || i !== u || (n = !0, l || (s = u)), l ? e.hide() : e.show()
            }), u !== s && n && i[e](s)
        }

        function n(a) {
            var n = [];
            r.find("ul.dropdown-menu").children().each(function () {
                var e = $(this),
                    i = e.data("value") + "";
                u = u || [], t.indexOf(i) > -1 ? (e.show(), u.indexOf(i) > -1 && n.push(i)) : e.hide()
            }), u.length !== n.length && i[e](n)
        }

        function s(e) {
            var t = e.indexOf(u) > -1,
                i = r.find("select"),
                a = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>");
            i.html("<option value=''>（请选择...）</option>" + a.render(e)).val(t ? u : ""), t || i.trigger("change")
        }
        var l, o, d, r, u, p = this.dispItems.filter(function (t) {
                return t.key === e
            }),
            c = p.length > 0 ? p[0] : null,
            h = this.fieldInstance.config && this.fieldInstance.config.isComplex,
            m = i._$row;
        return c && ($.isArray(c.options) || c.optionsConfig) ? (l = mediForm.util.getEffectiveOptions(c), o = t.filter(function (e) {
            return l.indexOf(e) > -1
        }), d = o.length, c.allowFill && d++, r = h ? m.find(".simple-object").children(".form-group[data-subkey='" + e + "']") : m.children("td[data-subkey='" + e + "']"), r.find(".field-value").length > 0 ? d : (u = i[e](), c.allowFill ? a(o) : c.subtype ? n(o) : s(o), d)) : -1
    }, mediForm.ctrls.SimpleObjectCtrl = function () {
        this.dispItems = []
    }, mediForm.ctrls.registerType("SimpleObject", mediForm.ctrls.SimpleObjectCtrl), mediForm.ctrls.SimpleObjectCtrl.prototype.internalRender = function (e) {
        function t(t) {
            var i = t.unit ? "border-top-right-radius:0px;border-bottom-right-radius:0px;" : "",
                a = e ? "min-width" : "width";
            if (t.options && !t.allowFill && !t.subtype) return "";
            if (t.width) return " style='" + i + a + ":" + t.width + "'";
            if (t.subtype) return " style='" + i + a + ":150px'";
            switch (t.type) {
                case "integer":
                case "float":
                    return " style='" + i + a + ":80px'";
                case "date":
                    return " style='" + i + a + ":120px'";
                case "textarea":
                case "rich":
                    return " style='" + i + a + ":400px'";
                default:
                    return " style='" + i + a + ":100px'"
            }
        }

        function i(e) {
            var i = e.unit ? "border-top-right-radius:0px;border-bottom-right-radius:0px;" : "",
                a = e.skipInput ? " skip-input" : "";
            if ($.isArray(e.options) || e.optionsConfig)
                if (e.allowFill) n.push("<div class='input-group dropdown combo" + a + "'>"), n.push(" <input type='text' class='form-control' " + t(e) + " data-bind='value: " + e.key + "' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' style='" + i + "' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(l.render(mediForm.util.getEffectiveOptions(e))), n.push("     </ul>"), n.push(" </div>"), n.push("</div>");
                else if (e.subtype) {
                var d = $.map(mediForm.util.getEffectiveOptions(e), function (t) {
                    return {
                        key: e.key,
                        option: t
                    }
                });
                n.push("<div class='input-group dropdown checkList" + a + "'>"), n.push(" <input type='text' class='form-control' " + t(e) + " data-bind='value: " + e.key + "' readonly='readonly' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(o.render(d)), n.push("     </ul>"), n.push(" </div>"), n.push("</div>")
            } else n.push("<select  style= '" + i + "' class='form-control" + a), e.search && n.push(" selectpicker"), n.push("'"), n.push(" data-bind='value:" + e.key + "'>"), n.push("<option value=''>（请选择...）</option>"), n.push(s.render(mediForm.util.getEffectiveOptions(e))), n.push("</select>");
            else "rich" === e.type ? n.push("<div class='froala-editor" + a + "' " + t(e) + " data-bind='froala: " + e.key + "'></div>") : "textarea" === e.type ? (n.push("<textarea class='form-control auto-sizable" + a + "' rows='1' data-bind='value: " + e.key + "' "), n.push(t(e) + "></textarea>")) : (n.push("<input type='text' class='form-control" + a), "date" === e.type && n.push(" calendar"), n.push("' data-bind='value: " + e.key + "' "), n.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), n.push(t(e) + " />"))
        }
        var a = this,
            n = [],
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            l = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>"),
            o = $.templates("<li role='presentation' data-value='{{attr: option}}' data-bind='mediCheckList: {{:key}}'><a role='menuitem' tabindex='-1' href='#'><span class='fa fa-fw'></span> {{> option}}</a></li>");
        this.dispItems = [], $.map(a.fieldInstance.data.sub, function (e) {
            a.dispItems.push(e)
        });
        var d = "field-inline-control-noTitle";
        a.fieldInstance.layout.hideTitle || (d = "field-inline-control", n.push("<div class='field-inline-label'><label class='control-label'>" + a.fieldInstance.name + "</label></div>")), n.push("<div class='" + d + " form-inline has-group simple-object'>"), $.map(this.dispItems, function (s) {
            var l = "rich" === s.type ? "html" : "text";
            s.newLine && n.push("<div></div>"), n.push("<div class='form-group medi-tip medi-compare' data-path='" + a.fieldInstance.key + "." + s.key + (s.subtype ? "#" : "") + "' data-subkey='" + s.key + "'>"), n.push("    <div class='input-group'>"), n.push("        <div class='input-group-addon'>" + s.name + "</div>"), e ? n.push("<div class='form-control field-value " + (s.subtype || s.type) + "'" + t(s) + " data-bind='" + l + ": " + s.key + "'></div>") : s.readonly ? n.push("<div class='form-control field-value field-readonly " + (s.subtype || s.type) + "'" + t(s) + " data-bind='" + l + ": " + s.key + "'></div>") : i(s), s.unit && n.push("        <div class='input-group-addon'>" + s.unit + "</div>"), n.push("    </div>"), n.push("    <div class='error-msg' data-bind='validationMessage: " + s.key + "'></div>"), n.push("</div>")
        }), n.push("</div>"), this.$container.html(n.join("")), a.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), a.$container.find("button.dropdown-toggle").dropdown(), a.$container.find(".selectpicker").selectpicker({
            liveSearch: !0,
            noneResultsText: "无相关数据",
            width: "auto",
            size: 10
        }).selectpicker("refresh"), a.$container.delegate("textarea.auto-sizable", "keyup", $.debounce(200, !1, function () {
            mediForm.util.autoSizeTextarea(this, 1, 9)
        })).delegate("div.dropdown", "shown.bs.dropdown", function () {
            $(this).find("ul.dropdown-menu").outerWidth($(this).outerWidth())
        }).delegate(".combo ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), $(this).parents(".dropdown:eq(0)").children("input").val($(this).text()).trigger("change")
        }), a.$container.delegate(".checkList ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), e.stopPropagation()
        })
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.SimpleObjectCtrl.base.getValue.call(this);
        return $.map(this.dispItems, function (t) {
            t.subtype && !e[t.key] && (e[t.key] = []), t.subtype || "" !== $.trim(e[t.key]) || (e[t.key] = null), "integer" !== t.type && "float" !== t.type || null === e[t.key] || (e[t.key] = parseFloat(e[t.key]))
        }), e
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.setValue = function (e) {
        var t = this;
        this.correctValue(e), mediForm.ctrls.SimpleObjectCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update"), t.$container.find(".selectpicker").selectpicker({
            liveSearch: !0,
            noneResultsText: "无相关数据",
            width: "auto",
            size: 10
        }).selectpicker("refresh"), window.setTimeout(function () {
            t.$container.find("textarea.auto-sizable").each(function () {
                mediForm.util.autoSizeTextarea(this, 1, 9)
            })
        }, 0)
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.hideSubItem = function (e) {
        this.$container.find(".simple-object").children(".form-group[data-subkey='" + e + "']").hide()
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.showSubItem = function (e) {
        this.$container.find(".simple-object").children(".form-group[data-subkey='" + e + "']").show()
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.disableSubItem = function (e) {
        this.$container.find(".simple-object").children(".form-group[data-subkey='" + e + "']").find("input, textarea, select, button").prop("disabled", !0)
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.enableSubItem = function (e) {
        this.$container.find(".simple-object").children(".form-group[data-subkey='" + e + "']").find("input, textarea, select, button").prop("disabled", !1)
    }, mediForm.ctrls.SimpleObjectCtrl.prototype.setOptions = function (e, t) {
        function i(i) {
            var a = !1,
                n = "";
            d.find("ul.dropdown-menu").children().each(function () {
                var e = $(this),
                    i = e.find("a").text(),
                    s = "none" === e.css("display"),
                    l = t.indexOf(i) < 0;
                s || i !== u || (a = !0, l || (n = u)), l ? e.hide() : e.show()
            }), u !== n && a && r[e](n)
        }

        function a(i) {
            var a = [];
            d.find("ul.dropdown-menu").children().each(function () {
                var e = $(this),
                    i = e.data("value") + "";
                u = u || [], t.indexOf(i) > -1 ? (e.show(), u.indexOf(i) > -1 && a.push(i)) : e.hide()
            }), u.length !== a.length && r[e](a)
        }

        function n(e) {
            var t = e.indexOf(u) > -1,
                i = d.find("select"),
                a = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>");
            i.html("<option value=''>（请选择...）</option>" + a.render(e)).val(t ? u : ""), t || i.trigger("change")
        }
        var s, l, o, d, r, u, p = this.dispItems.filter(function (t) {
                return t.key === e
            }),
            c = p.length > 0 ? p[0] : null;
        return c && ($.isArray(c.options) || c.optionsConfig) ? (s = mediForm.util.getEffectiveOptions(c), l = t.filter(function (e) {
            return s.indexOf(e) > -1
        }), o = l.length, c.allowFill && o++, d = this.$container.find(".simple-object").children(".form-group[data-subkey='" + e + "']"), d.find(".field-value").length > 0 ? o : (r = this.koValue(), u = r[e](), c.allowFill ? i(l) : c.subtype ? a(l) : (n(l), c.search && d.find(".selectpicker").selectpicker("refresh")), o)) : -1
    }, mediForm.ctrls.SimpleTableCtrl = function () {
        this.dispItems = []
    }, mediForm.ctrls.registerType("SimpleTable", mediForm.ctrls.SimpleTableCtrl), mediForm.ctrls.SimpleTableCtrl.prototype.internalRender = function (e) {
        function t(t, i) {
            var a = e ? "min-width" : "width";
            return " style='" + a + ":" + (i ? i : "100%") + ";min-width:100px;'"
        }

        function i(e, i) {
            var a = e.skipInput ? " skip-input" : "";
            if ($.isArray(e.options) || e.optionsConfig)
                if (e.allowFill) i && (i = parseFloat(i) - 24 + "px"), n.push("<div class='input-group dropdown combo" + a + "' style='width:100%;'>"), n.push(" <input type='text' class='form-control' " + t(e, i) + " data-bind='value: " + e.key + "' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(o.render(mediForm.util.getEffectiveOptions(e))), n.push("     </ul>"), n.push(" </div>"), n.push("</div>");
                else if (e.subtype) {
                i && (i = parseFloat(i) - 24 + "px");
                var s = $.map(mediForm.util.getEffectiveOptions(e), function (t) {
                    return {
                        key: e.key,
                        option: t
                    }
                });
                n.push("<div class='input-group dropdown checkList" + a + "' style='width:100%;'>"), n.push(" <input type='text' class='form-control' " + t(e, i) + " data-bind='value: " + e.key + "' readonly='readonly' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(d.render(s)), n.push("     </ul>"), n.push(" </div>"), n.push("</div>")
            } else n.push("<select class='form-control" + a + "' data-bind='value:" + e.key + "' style='width:" + i + "'>"), n.push("<option value=''>（请选择...）</option>"), n.push(l.render(mediForm.util.getEffectiveOptions(e))), n.push("</select>");
            else "rich" === e.type ? n.push("<div class='froala-editor" + a + "' style='width:100%;' data-bind='froala: " + e.key + "'></div>") : "textarea" === e.type ? (n.push("<textarea class='form-control auto-sizable" + a + "' rows='1' data-bind='value: " + e.key + "' "), n.push(t(e, i) + "></textarea>")) : (n.push("<input type='text' class='form-control" + a), "date" === e.type && n.push(" calendar"), n.push("' data-bind='value: " + e.key + "' "), n.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), n.push(t(e, i) + " />"))
        }
        var a = this,
            n = [],
            s = {},
            l = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            o = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>"),
            d = $.templates("<li role='presentation' data-value='{{attr: option}}' data-bind='mediCheckList: {{:key}}'><a role='menuitem' tabindex='-1' href='#'><span class='fa fa-fw'></span> {{> option}}</a></li>");
        this.dispItems = [], $.map(a.fieldInstance.data.sub, function (e) {
            a.dispItems.push(e)
        });
        var r = "field-inline-control-noTitle";
        a.fieldInstance.layout.hideTitle || (r = "field-inline-control", n.push("<div><span class='field-title'>" + a.fieldInstance.name + "</span></div>")), n.push("<div class='simple-table' style='height:" + a.fieldInstance.config.maxHeight + ";max-width:" + a.$container.width() + "px;'>"), n.push("<table id='" + a.fieldInstance.key + "' class='table table-hover repeatTable-table medi-compare'  freezeRowNum='1' freezeColumnNum='1' >"), n.push("<thead>"), n.push("<th >" + a.fieldInstance.config.leftTopTitle + "</th>"), $.map(a.fieldInstance.config.columns, function (e) {
            var t = e.name;
            a.fieldInstance.config.hideHeader && a.fieldInstance.config.hideHeader.column && (t = ""), e.width && (s[e.key] = e.width), n.push("<th>" + t + "</th>")
        }), n.push("</thead>"), n.push("<tbody>"), $.map(a.fieldInstance.config.rows, function (l, o) {
            var d = l.name;
            a.fieldInstance.config.hideHeader && a.fieldInstance.config.hideHeader.row && (d = ""), n.push("<tr>"), n.push('<td style="width:120px;white-space:normal;text-align:center;">' + d + "</td>"), $.map(a.dispItems, function (o, d) {
                var r = o.key.split("_");
                if (r[1] === l.key) {
                    n.push("<td  data-path='" + a.fieldInstance.key + "." + o.key + (o.subtype ? "#" : "") + "' data-subkey='" + o.key + "'>");
                    var u = "rich" === o.type ? "html" : "text";
                    e ? o.text ? n.push("<div class='field-value " + (o.subtype || o.type) + "'" + t(o, s[r[0]]) + "'>" + o.text + "</div>") : n.push("<div class='form-control field-value " + (o.subtype || o.type) + "'" + t(o, s[r[0]]) + " data-bind='" + u + ": " + o.key + "'></div>") : o.text ? n.push("<div class=' field-value " + (o.subtype || o.type) + "'" + t(o, s[r[0]]) + "'>" + o.text + "</div>") : o.readonly ? n.push("<div class='form-control field-value field-readonly " + (o.subtype || o.type) + "'" + t(o, s[r[0]]) + " data-bind='" + u + ": " + o.key + "' ></div>") : i(o, s[r[0]]), n.push("</td>")
                }
            })
        }), n.push("</tbody>"), n.push("</table>"), n.push("</div>"), this.$container.html(n.join("")), a.$container.find(".simple-table table").fixedHeaderTable({
            altClass: "odd",
            footer: !0,
            fixedColumns: 1
        }), a.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), a.$container.find("button.dropdown-toggle").dropdown(), a.$container.delegate("textarea.auto-sizable", "keyup", $.debounce(200, !1, function () {
            mediForm.util.autoSizeTextarea(this, 1, 9)
        })).delegate("div.dropdown", "shown.bs.dropdown", function () {
            $(this).find("ul.dropdown-menu").outerWidth($(this).outerWidth())
        }).delegate(".combo ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), $(this).parents(".dropdown:eq(0)").children("input").val($(this).text()).trigger("change")
        }), a.$container.delegate(".checkList ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), e.stopPropagation()
        }), window.setTimeout(function () {
            a.$container.find(".froala-editor").css({
                width: "100%",
                "min-width": "100px"
            })
        }, 0)
    }, mediForm.ctrls.SimpleTableCtrl.prototype.getDefaultValue = function () {
        var e = {};
        return $.each(this.fieldInstance.data.sub, function (t, i) {
            switch (i.type) {
                case "arrayOfValue":
                case "arrayOfObject":
                    e[i.key] = i.defaultValue ? [i.defaultValue] : [];
                    break;
                default:
                    e[i.key] = i.defaultValue ? i.defaultValue : null
            }
        }), e
    }, mediForm.ctrls.SimpleTableCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.SimpleTableCtrl.base.getValue.call(this);
        return $.map(this.dispItems, function (t) {
            t.subtype && !e[t.key] && (e[t.key] = []), t.subtype || "" !== $.trim(e[t.key]) || (e[t.key] = null), "integer" !== t.type && "float" !== t.type || null === e[t.key] || (e[t.key] = parseFloat(e[t.key]))
        }), e
    }, mediForm.ctrls.SimpleTableCtrl.prototype.setValue = function (e) {
        var t = this;
        this.correctValue(e), mediForm.ctrls.SimpleTableCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update"), window.setTimeout(function () {
            t.$container.find("textarea.auto-sizable").each(function () {
                mediForm.util.autoSizeTextarea(this, 1, 9)
            })
        }, 0)
    }, mediForm.ctrls.SliderCtrl = function () {}, mediForm.ctrls.registerType("Slider", mediForm.ctrls.SliderCtrl), mediForm.ctrls.SliderCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (a = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + a + "'>");
        var n = t.fieldInstance.config.minValueText || "",
            s = t.fieldInstance.config.maxValueText || "",
            l = t.fieldInstance.config.minValue,
            o = t.fieldInstance.config.maxValue,
            d = t.fieldInstance.config.step;
        e ? i.push("<div><span class='field-inline-sliderValue' data-bind='text: value'></span><span class='field-inline-sliderText'>" + n + "</span><input class='field-inline-slider' type='text' data-bind='sliderValue: {value: value, min:" + l + ", max: " + o + ", step: " + d + ", enabled:false}'/><span class='field-inline-sliderText'>" + s + "</span></div>") : (i.push("<div class='form-group'>"), t.fieldInstance.config.disableTyping ? i.push("<span class='field-inline-sliderValue' data-bind='text: value'></span>") : i.push("<input type='text' class='form-control field-inline-sliderInput' data-bind='value: value'/>"), i.push("<span class='field-inline-sliderText'>" + n + "</span><input class='field-inline-slider' type='text' data-bind='sliderValue: {value: value, min:" + l + ", max: " + o + ", step: " + d + ", tooltip:\"hide\"}'/><span class='field-inline-sliderText'>" + s + "</span></div>")), i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join(""))
    }, mediForm.ctrls.SliderCtrl.prototype.getDefaultValue = function () {
        return {
            value: parseFloat(this.fieldInstance.config["default"])
        }
    }, mediForm.ctrls.SliderCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.SliderCtrl.base.setValue.call(this, parseFloat(e))
    }, mediForm.ctrls.SmokeHistoryCtrl = function () {}, mediForm.ctrls.registerType("SmokeHistory", mediForm.ctrls.SmokeHistoryCtrl), mediForm.ctrls.SmokeHistoryCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = mediForm.util.getTextValidateTag(!1, "float"),
            a = [];
        a.push("<table class='xiYanShi-table'><tbody>"), a.push(" <tr>"), t.fieldInstance.layout.hideTitle ? a.push("     <td class='yesNo medi-tip medi-compare' colspan='2' data-path='" + t.fieldInstance.key + ".shiFouXiYan'>") : (a.push("     <td class='title'><label class='control-label'>" + this.fieldInstance.name + "</label></td>"), a.push("     <td class='yesNo medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".shiFouXiYan'>")), e ? a.push("<span class='field-value' data-bind='text: shiFouXiYan'></span>") : (a.push("         <label class='radio-inline' style='margin-right:20px'>"), a.push("             <input type='radio' name='" + this.fieldInstance.key + "_xiYan' value='有' data-bind='checked: shiFouXiYan' />有"), a.push("         </label>"), a.push("         <label class='radio-inline' style='margin-right:20px'>"), a.push("             <input type='radio' name='" + this.fieldInstance.key + "_xiYan' value='无' data-bind='checked: shiFouXiYan' />无"), a.push("         </label>")), a.push("     </td>"), a.push("     <td data-bind='visible: shiFouXiYan() === \"有\"' class='title2'><label class='control-label'>吸烟累计年数</label></td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".xiYanNianShu' data-bind='visible: shiFouXiYan() === \"有\"'>"), e ? a.push("<span class='field-value' data-bind='text: xiYanNianShu'></span>") : a.push("<input type='text' class='form-control' data-bind='value: xiYanNianShu' " + i + " />"), a.push("     </td>"), a.push(" </tr>"), a.push(" <tr data-bind='visible: shiFouXiYan() === \"有\"'>"), a.push("     <td class='title'><label class='control-label'>是否戒烟</label></td>"), a.push("     <td class='yesNo medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".shiFouJieYan'>"), e ? a.push("<span class='field-value' data-bind='text: shiFouJieYan'></span>") : (a.push("         <label class='radio-inline' style='margin-right:20px'>"), a.push("             <input type='radio' name='" + this.fieldInstance.key + "_jieYan' value='是' data-bind='checked: shiFouJieYan' />是"), a.push("         </label>"), a.push("         <label class='radio-inline' style='margin-right:20px'>"), a.push("             <input type='radio' name='" + this.fieldInstance.key + "_jieYan' value='否' data-bind='checked: shiFouJieYan' />否"), a.push("         </label>")), a.push("     </td>"), a.push("     <td data-bind='visible: shiFouJieYan() === \"是\"' class='title2'><label class='control-label'>戒烟年数</label></td>"), a.push("     <td class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".jieYanNianShu' data-bind='visible: shiFouJieYan() === \"是\"'>"), e ? a.push("<span class='field-value' data-bind='text: jieYanNianShu'></span>") : a.push("<input type='text' class='form-control' data-bind='value: jieYanNianShu' " + i + " />"), a.push("     </td>"), a.push(" </tr>"), a.push("</tbody></table>"), this.$container.html(a.join("")), this.koValue.shiFouXiYan.subscribe(function (e) {
            "无" === e && t.koValue().xiYanNianShu(null)
        }), this.koValue.shiFouJieYan.subscribe(function (e) {
            "否" === e && t.koValue().jieYanNianShu(null)
        })
    }, mediForm.ctrls.SmokeHistoryCtrl.prototype.getDefaultValue = function () {
        return {
            shiFouXiYan: "无",
            xiYanNianShu: null,
            shiFouJieYan: "否",
            jieYanNianShu: null
        }
    }, mediForm.ctrls.SmokeHistoryCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.SmokeHistoryCtrl.base.getValue.call(this);
        return e.xiYanNianShu && (e.xiYanNianShu = parseFloat(e.xiYanNianShu)), e.jieYanNianShu && (e.jieYanNianShu = parseFloat(e.jieYanNianShu)), e
    }, mediForm.ctrls.TestComplexResultCtrl = function () {
        this.subItemMap = {}, this.subItemKeys = []
    }, mediForm.ctrls.registerType("TestComplexResult", mediForm.ctrls.TestComplexResultCtrl), mediForm.ctrls.TestComplexResultCtrl.prototype.internalRender = function (e) {
        function t(e, t, s) {
            var l, o = a.subItemMap[e];
            n.push("<td class='td-del perm-edit'>"), t && (n.push("<a href='javascript:void(0)' data-bind='click: $root.result." + e + ".removeItem' title='删除'>"), n.push("<span class='glyphicon glyphicon-remove'></span></a>")), n.push("</td>"), $.map(a.subItemKeys, function (d) {
                "_config" !== d && "_repeat" !== d && (l = " class='medi-compare' data-path='" + a.fieldInstance.key + ".result." + e + ".detail" + (t ? "#'" : "'"), n.push("<td" + (o[d] ? l : "") + ">"), o[d] && (n.push("<div class='medi-tip' data-path='" + a.fieldInstance.key + ".result." + e + ".detail" + (t ? "#." : ".") + d + "'>"), i(o[d], e, t, s), n.push("</div>")), n.push("</td>"))
            })
        }

        function i(t, i, a, s) {
            var l = t.skipInput ? " skip-input" : "",
                o = a ? t.key : "result." + i + ".detail." + t.key;
            e || t.readonly ? n.push("<span class='field-value' data-bind='text: " + o + "'></span>") : $.isArray(t.options) ? t.allowFill ? (n.push("<div class='input-group dropdown" + l + "' data-bind='" + s + "'>"), n.push(" <input type='text' class='form-control' data-bind='value: " + o + "' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(r.render(t.options)), n.push("     </ul>"), n.push(" </div>"), n.push("</div>")) : (n.push("<select class='form-control" + l + "' data-bind='value:" + o + ", " + s + "'>"), n.push("<option value=''>（请选择...）</option>"), n.push(d.render(t.options)), n.push("</select>")) : (n.push("<input type='text' class='form-control" + l), "date" === t.type && n.push(" calendar"), n.push("' data-bind='value: " + o + ", " + s + "' placeholder='" + t.name + "' "), n.push(mediForm.util.getTextValidateTag(!1, t.type, t.pattern)), n.push(" />"))
        }
        var a = this,
            n = [],
            s = mediForm.util.findKeyInSub(a.fieldInstance.data, "result").sub,
            l = [],
            o = !1,
            d = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            r = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>");
        $.map(s, function (e) {
            var t = mediForm.util.findKeyInSub(e, "detail"),
                i = t.sub;
            a.subItemMap[e.key] = {
                _config: e,
                _repeat: "arrayOfObject" === t.type
            }, $.map(i, function (t) {
                a.subItemMap[e.key][t.key] = t, -1 === $.inArray(t.key, a.subItemKeys) && (a.subItemKeys.push(t.key), l.push(t.name))
            })
        }), a.fieldInstance.layout.hideTitle || n.push("<div><span class='field-title'>" + a.fieldInstance.name + "</span></div>"), n.push("<table class='table complexResult-table'>"), n.push(" <thead><tr>"), n.push("     <th style='width:120px'>日期</th><th style='width: 50px'>项目</th>"), n.push("     <th style='width: 20px'>未查</th><th style='width: 20px'>未见异常</th><th style='width: 20px'>异常</th>"), n.push("     <th style='width: 30px' class='perm-edit'>&nbsp;</th>"), $.map(l, function (e) {
            n.push("<th>" + e + "</th>")
        }), n.push(" </tr></thead>"), n.push(" <tbody>"), $.each(a.subItemMap, function (i, s) {
            n.push("<tr>"), o || (n.push("<td rowspan='999' class='medi-tip medi-compare' data-path='" + a.fieldInstance.key + ".testDate'>"), e ? n.push("<span class='field-value' data-bind='text: testDate'></span>") : n.push("<input type='text' class='form-control testDate' pattern='^\\d{4}-\\d{2}-\\d{2}$' data-bind='value: testDate' />"), n.push("</td>"), o = !0);
            var l = s._repeat ? " data-bind='attr: {rowspan: result." + i + ".detail().length + 1}'" : "",
                d = "visible: $root.result." + i + '.overview() === "异常"';
            n.push(" <td class='medi-tip medi-compare' data-path='" + a.fieldInstance.key + ".result." + i + ".overview'" + l + ">" + s._config.name + "</td>"), n.push(" <td" + l + " class='text-center medi-compare' data-path='" + a.fieldInstance.key + ".result." + i + ".overview'>"), n.push("     <input type='radio' value='未查' name='" + a.fieldInstance.key + "_" + i + "'"), e && n.push(" disabled='disabled'"), n.push("         data-bind='checked: result." + i + ".overview' />"), n.push(" </td>"), n.push(" <td" + l + " class='text-center medi-compare' data-path='" + a.fieldInstance.key + ".result." + i + ".overview'>"), n.push("     <input type='radio' value='未见异常' name='" + a.fieldInstance.key + "_" + i + "'"), e && n.push(" disabled='disabled'"), n.push("         data-bind='checked: result." + i + ".overview' />"), n.push(" </td>"), n.push(" <td" + l + " class='text-center medi-compare' data-path='" + a.fieldInstance.key + ".result." + i + ".overview'>"), n.push("     <input type='radio' value='异常' name='" + a.fieldInstance.key + "_" + i + "'"), e && n.push(" disabled='disabled'"), n.push("         data-bind='checked: result." + i + ".overview' />"), n.push(" </td>"), s._repeat ? (n.push(" <td colspan='" + (a.subItemKeys.length + 1).toString() + "' class='td-add perm-edit'>"), n.push("     <a href='javascript:void(0)' data-bind='click: result." + i + ".addItem, " + d + "'>"), n.push("     <span class='glyphicon glyphicon-plus'></span> 添加新结果</a>"), n.push(" </td>"), n.push("</tr>"), n.push("<!-- ko foreach: result." + i + ".detail -->"), n.push("<tr data-jiancha='" + i + "'>"), t(i, !0), n.push("</tr>"), n.push("<!-- /ko -->")) : (t(i, !1, d), n.push("</tr>"))
        }), n.push(" </tbody>"), n.push("</table>"), a.$container.html(n.join("")), a.$container.find("input.testDate").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), a.$container.find("input:radio").parent("td").on("click", function (e) {
            var t = $(this).children(":radio");
            1 == t.length && (t.prop("disabled") || t.prop("checked") || (t.prop("checked", !0), t.click()))
        }), a.$container.find("button.dropdown-toggle").dropdown(), a.$container.delegate("div.dropdown", "shown.bs.dropdown", function () {
            $(this).find("ul.dropdown-menu").outerWidth($(this).outerWidth())
        }).delegate("ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), $(this).parents(".dropdown:eq(0)").children("input").val($(this).text()).trigger("change")
        }), $.each(a.subItemMap, function (e, t) {
            a.koValue.result[e].overview.subscribe(function (i) {
                "异常" !== i && (t._repeat ? a.koValue().result[e].detail([]) : $.map(a.subItemKeys, function (i) {
                    t[i] && a.koValue().result[e].detail[i](null)
                }))
            }), t._repeat && (a.koValue.result[e].addItem = function () {
                var t = {};
                $.each(a.subItemMap[e], function (e, i) {
                    t[e] = ko.observable(null)
                }), a.koValue().result[e].detail.push(t), a.$container.find(".repeatTable-table > tbody > tr[data-jiancha='" + e + "']:last input.calendar").datepicker({
                    todayBtn: "linked",
                    format: "yyyy-mm-dd",
                    language: "zh-CN",
                    autoclose: !0
                }), a.$container.find(".repeatTable-table > tbody > tr[data-jiancha='" + e + "']:last button.dropdown-toggle").dropdown()
            }, a.koValue.result[e].removeItem = function (t) {
                a.koValue().result[e].detail.remove(t)
            })
        })
    }, mediForm.ctrls.TestComplexResultCtrl.prototype.getDefaultValue = function () {
        var e = mediForm.ctrls.TestComplexResultCtrl.base.getDefaultValue.call(this);
        return $.each(e.result, function (e, t) {
            t.overview = "未查"
        }), e
    }, mediForm.ctrls.TestComplexResultCtrl.prototype.getValue = function () {
        function e(e, t) {
            e && (delete e._config, delete e._repeat, $.map(i.subItemKeys, function (i) {
                t[i] && ("" === $.trim(e[i]) && (e[i] = null), null === e[i] || "integer" !== t[i].type && "float" !== t[i].type || (e[i] = parseFloat(e[i])))
            }))
        }
        var t = mediForm.ctrls.TestComplexResultCtrl.base.getValue.call(this),
            i = this;
        return $.each(this.subItemMap, function (i, a) {
            a._repeat ? (delete t.result[i].addItem, delete t.result[i].removeItem, $.map(t.result[i].detail, function (t) {
                e(t, a)
            })) : e(t.result[i].detail, a)
        }), t
    }, mediForm.ctrls.TestComplexResultCtrl.prototype.setValue = function (e) {
        var t = this;
        t.correctValue(e), $.each(t.subItemMap, function (i, a) {
            "异常" !== e.result[i].overview && (a._repeat ? e.result[i].detail = [] : $.map(t.subItemKeys, function (t) {
                a[t] && (e.result[i].detail[t] = null)
            }))
        }), mediForm.ctrls.TestComplexResultCtrl.base.setValue.call(this, e), this.$container.find("input.testDate").datepicker("update"), this.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), this.$container.find("button.dropdown-toggle").dropdown()
    }, mediForm.ctrls.TestMinusPlusCtrl = function () {
        this.dispItems = {
            items: []
        }
    }, mediForm.ctrls.registerType("TestMinusPlus", mediForm.ctrls.TestMinusPlusCtrl), mediForm.ctrls.TestMinusPlusCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = mediForm.util.findKeyInSub(t.fieldInstance.data, "result").sub,
            n = 0;
        $.map(a, function (e) {
            for (var i = mediForm.util.findKeyInSub(e, "detail"), a = "", s = {
                    key: e.key,
                    name: e.name,
                    hasDetail: !!i,
                    options: ["未查", "(-)"]
                }, l = 1; l <= e.maxPlus; l++) a += "+", s.options.push("(" + a + ")");
            n < e.maxPlus && (n = e.maxPlus), t.dispItems.items.push(s)
        }), $.map(t.dispItems.items, function (e) {
            e.leftCol = n + 2 - e.options.length
        });
        var s = !!mediForm.util.findKeyInSub(t.fieldInstance.data, "testDate");
        t.fieldInstance.layout.hideTitle || i.push("<div><span class='field-title'>" + t.fieldInstance.name + "</span></div>"), i.push("<table class='table table-hover minusPlus-table'><tbody>"), i.push("{{for items}}"), i.push("<tr>"), s && (i.push("{{if #index == 0}}"), i.push("<td style='width:120px' rowspan='99' class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".testDate'>"), i.push("<strong>日期</strong><br/>"), e ? i.push("<span class='field-value' data-bind='text: testDate'></span>") : i.push("<input type='text' class='form-control calendar' pattern='^\\d{4}-\\d{2}-\\d{2}$' data-bind='value: testDate' />"), i.push("</td>"), i.push("{{/if}}")), i.push("<td class='name medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".result.{{:key}}'><strong>{{>name}}</strong></td>"), i.push("{{for options}}"), i.push("    <td class='medi-compare' data-path='" + t.fieldInstance.key + ".result.{{:#parent.parent.data.key}}.result'><div class='radio'><label><input type='radio' "), e && i.push("disabled='disabled' "), i.push("        name='" + t.fieldInstance.key + "_{{: #parent.parent.data.key}}' "), i.push("        data-bind='checked: result.{{: #parent.parent.data.key}}.result' "), i.push("        value='{{attr: #data}}' />{{: #data}}</label></div></td>"), i.push("{{/for}}"), i.push("{{if leftCol > 0}}<td colspan='{{:leftCol}}'></td>{{/if}}"), i.push("<td style='width:120px;white-space:nowrap;' {{if hasDetail}}class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".result.{{:key}}.detail'{{/if}}>"), i.push("{{if hasDetail}}"), e ? i.push("数值：<span class='field-value' data-bind='text: result.{{:key}}.detail'></span>") : (i.push("<input type='text' class='form-control' placeholder='检查数值' "), i.push("    data-bind='value: result.{{:key}}.detail, "), i.push('        visible: result.{{:key}}.result() != "未查"\'/>')), i.push("{{/if}}"), i.push("</td>"), i.push("</tr>"), i.push("{{/for}}"), i.push("</tbody></table>"), t.$container.html($.templates(i.join("")).render(t.dispItems)), t.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        })
    }, mediForm.ctrls.TestMinusPlusCtrl.prototype.getDefaultValue = function () {
        var e = mediForm.ctrls.TestMinusPlusCtrl.base.getDefaultValue.call(this);
        return $.each(e.result, function (e, t) {
            t.result = "未查"
        }), e
    }, mediForm.ctrls.TestMinusPlusCtrl.prototype.setValue = function (e) {
        this.correctValue(e), mediForm.ctrls.TestMinusPlusCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.TestResultCtrl = function () {
        this.dispItems = {
            items: []
        }, this.normalMap = {}
    }, mediForm.ctrls.registerType("TestResult", mediForm.ctrls.TestResultCtrl), mediForm.ctrls.TestResultCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = !t.fieldInstance.config.disableCheckNormal,
            a = [],
            n = mediForm.util.findKeyInSub(t.fieldInstance.data, "result").sub;
        $.map(n, function (e) {
            var i = $.extend({}, e);
            switch (i.type) {
                case "integer":
                    i.validation = "pattern='^正常$|^(\\-|\\+)?\\d+$'";
                    break;
                case "float":
                    i.validation = "pattern='^正常$|^(\\-|\\+)?\\d+(\\.\\d+)?$'";
                    break;
                default:
                    i.validation = ""
            }
            t.dispItems.items.push(i), t.normalMap[i.key] = i.options && i.normalRange ? i.normalRange : "正常"
        }), a.push("<div>"), t.fieldInstance.layout.hideTitle || a.push("<span class='field-title'>" + t.fieldInstance.name + "</span>"), i && a.push("<button class='btn btn-sm btn-success pull-right perm-edit' data-bind='click: allClear'>标记为全部正常</button>"), a.push("</div>"), a.push("<table class='table testResult-table" + (i ? " checkNormal" : "") + "'>"), a.push("<thead>"), a.push("	<tr><th>日期</th><th>项目</th><th>缩写</th><th>化验值</th><th>结果单位</th><th>正常值范围</th></tr>"), a.push("</thead>"), a.push("<tbody>"), a.push("{{for items}}"), a.push("	<tr>"), a.push("	{{if #index == 0}}<td rowspan='99' class='medi-tip medi-compare {{if skipInput}}skip-input{{/if}}' data-path='" + t.fieldInstance.key + ".testDate' style='width:120px;'>"), e ? a.push("<span class='field-value' data-bind='text: testDate'></span>") : a.push("<input type='text' class='form-control calendar' pattern='^\\d{4}-\\d{2}-\\d{2}$' data-bind='value: testDate' />"), a.push("	</td>{{/if}}"), a.push("		<td>{{>name}}</td>"), a.push("		<td>{{:shortName}}</td>"), e ? (a.push("{{if options}}"), a.push("<td class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".result.{{:key}}'><span class='field-value testResult-result' data-bind='text: result.{{:key}}, "), a.push('        css: { normal: result.{{:key}}() == "{{attr: normalRange}}", uncheck: !result.{{:key}}() }\'></span></td>'), a.push("{{else}}"), a.push("<td class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".result.{{:key}}'><span class='field-value testResult-result' data-bind='text: result.{{:key}}, "), a.push('        css: { normal: result.{{:key}}() == "正常", uncheck: result.{{:key}}() == null }\'></span></td>'), a.push("{{/if}}")) : (a.push("<td class='medi-tip medi-compare {{if skipInput}}skip-input{{/if}}' data-path='" + t.fieldInstance.key + ".result.{{:key}}'>"), a.push("{{if options}}"), a.push("    <select class='form-control testResult-result' data-bind='value: result.{{:key}}, "), a.push('        css: { normal: result.{{:key}}() == "{{attr: normalRange}}", none: !result.{{:key}}() }\'>'), a.push("        <option class='testResult-result none' value=''>未查</option>"), a.push("        {{for options}}<option class='testResult-result {{if #data==#parent.parent.data.normalRange}}normal{{/if}}' value='{{attr: #data}}'>{{> #data}}</option>{{/for}}"), a.push("    </select>"), a.push("{{else}}"), a.push("    <input type='text' class='form-control testResult-result' placeholder='未查' "), a.push("		{{:validation}} data-bind='value: result.{{:key}}, css: { normal: result.{{:key}}() === \"正常\"}' />"), a.push("{{/if}}"), a.push("</td>")), a.push("		<td>{{:unit}}</td>"), a.push("		<td>{{>normalRange}}</td>"), a.push("	</tr>"), a.push("{{/for}}"), a.push("</tbody>"), a.push("</table>"), t.$container.html($.templates(a.join("")).render(t.dispItems)), t.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), t.koValue.allClear = function () {
            var e = t.koValue().result;
            $.each(e, function (i, a) {
                e[i](t.normalMap[i])
            })
        }
    }, mediForm.ctrls.TestResultCtrl.prototype.setValue = function (e) {
        this.correctValue(e), mediForm.ctrls.TestResultCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update")
    }, mediForm.ctrls.TestResultCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.TestResultCtrl.base.getValue.call(this),
            t = this.normalMap;
        return $.map(this.dispItems.items, function (i) {
            "" === $.trim(e.result[i.key]) && (e.result[i.key] = null), null === e.result[i.key] || e.result[i.key] === t[i.key] || "integer" !== i.type && "float" !== i.type || (e.result[i.key] = parseFloat(e.result[i.key]))
        }), $.isPlainObject(e.result) && !this.fieldInstance.config.disableCheckNormal && (e.allNormal = !0, $.each(e.result, function (i, a) {
            return null !== a && a !== t[i] ? (e.allNormal = !1, !1) : void 0
        })), e
    }, mediForm.ctrls.TextCtrl = function () {}, mediForm.ctrls.registerType("Text", mediForm.ctrls.TextCtrl), mediForm.ctrls.TextCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = mediForm.util.getTextValidateTag(t.fieldInstance.required, t.fieldInstance.data.type, t.fieldInstance.config.pattern),
            n = "field-inline-control-noTitle";
        if (t.fieldInstance.layout.hideTitle || (n = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), t.fieldInstance.config.unit ? (i.push("<div style='width:55px;float:right;padding:7px 0px 0 5px;word-wrap:break-word;'><label class='control-label'>" + t.fieldInstance.config.unit + "</label></div>"), i.push("<div class='" + n + "' style='margin-right:55px;'>")) : i.push("<div class='" + n + "'>"), e) t.fieldInstance.config.rich ? i.push("<span class='field-value' data-bind='html: value' style='white-space:pre-wrap;display:block;word-wrap:break-word;width: " + t.fieldInstance.config.width + " '></span>") : i.push("<span class='field-value' data-bind='text: value' style='white-space:pre-wrap'></span>");
        else if (t.fieldInstance.config.rich) i.push("<div class='froala-editor' data-bind='froala: value' style='width: " + (t.fieldInstance.config.width || "400px") + "'></div>");
        else if (t.fieldInstance.config.multiline) {
            var s = t.fieldInstance.config.lineCount || 3;
            i.push("<textarea class='form-control' rows='" + s + "' "), i.push(a), i.push("     data-bind='value: value'></textarea>")
        } else i.push("<input type='text' class='form-control' "), i.push(a), i.push("		data-bind='value: value' />");
        if (i.push("</div>"), t.$container.addClass("medi-tip medi-compare").attr("data-path", t.fieldInstance.key).html(i.join("")), t.fieldInstance.config.multiline) {
            var l = t.fieldInstance.config.lineCount || 3,
                o = t.fieldInstance.config.maxLineCount || 9999;
            l !== o && t.$container.delegate("textarea", "keyup", $.debounce(200, !1, function () {
                mediForm.util.autoSizeTextarea(this, l, o)
            }))
        }
    }, mediForm.ctrls.TextCtrl.prototype.getDefaultValue = function () {
        var e = this.fieldInstance.config["default"];
        if ("[today]" === e) {
            var t = new Date,
                i = t.getFullYear(),
                a = t.getMonth() + 1,
                n = t.getDate();
            return {
                value: i + "-" + (10 > a ? "0" : "") + a + "-" + (10 > n ? "0" : "") + n
            }
        }
        return e ? {
            value: e
        } : {
            value: ""
        }
    }, mediForm.ctrls.TextCtrl.prototype.getValue = function () {
        var e = ko.mapping.toJS(this.koValue).value,
            t = this.fieldInstance.data.type;
        return "integer" === t || "float" === t ? "undefined" == typeof e || null === e ? null : parseFloat(e) : e
    }, mediForm.ctrls.TNMStagingCtrl = function () {}, mediForm.ctrls.registerType("TNMStaging", mediForm.ctrls.TNMStagingCtrl), mediForm.ctrls.TNMStagingCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            n = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (n = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + n + " form-inline has-group'>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".tFenQi' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>T分期</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: tFenQi'></div>") : (i.push("<select class='form-control' data-bind='value: tFenQi'>"), i.push(" <option value=''>（请选择...）</option>"), i.push(a.render(["1", "1a", "1b", "2", "2a", "2b", "3", "4"])), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".nFenQi' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>N分期</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: nFenQi'></div>") : (i.push("<select class='form-control' data-bind='value: nFenQi'>"), i.push(" <option value=''>（请选择...）</option>"), i.push(a.render(["0", "1", "2", "3"])), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".mFenQi' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>M分期</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: mFenQi'></div>") : (i.push("<select class='form-control' data-bind='value: mFenQi'>"), i.push(" <option value=''>（请选择...）</option>"), i.push(a.render(["0", "1", "1a", "1b"])), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".fenQiJieGuo' style='margin-right:10px'>"), i.push("    <div class='input-group'>"),
            i.push("        <div class='input-group-addon'>分期结果</div>"), i.push("        <div class='form-control' style='width:100px' data-bind='text: fenQiJieGuo'></div>"), i.push("    </div>"), i.push("</div>"), t.$container.html(i.join("")), t.koValue.fenQiJieGuo = ko.pureComputed(function () {
                var e = this.tFenQi(),
                    t = this.nFenQi(),
                    i = this.mFenQi();
                if ("" === e || "" === t || "" === i) return "--";
                if ("0" !== i) return "Stage IV";
                var a = e.substr(0, 1) + t.substr(0, 1);
                switch (a) {
                    case "10":
                        return "Stage IA";
                    case "11":
                        return "Stage IIA";
                    case "12":
                        return "Stage IIIA";
                    case "13":
                        return "Stage IIIB";
                    case "20":
                        return "Stage IB";
                    case "21":
                        return "Stage IIA";
                    case "22":
                        return "Stage IIIA";
                    case "23":
                        return "Stage IIIB";
                    case "30":
                        return "Stage IIB";
                    case "31":
                        return "Stage IIIA";
                    case "32":
                        return "Stage IIIA";
                    case "33":
                        return "Stage IIIB";
                    case "40":
                        return "Stage IIIA";
                    case "41":
                        return "Stage IIIA";
                    case "42":
                        return "Stage IIIB";
                    case "43":
                        return "Stage IIIB"
                }
                return "--"
            }, t.koValue)
    }, mediForm.ctrls.TNMStagingCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.TNMStagingCtrl.base.setValue.call(this, {
            tFenQi: e.tFenQi,
            nFenQi: e.nFenQi,
            mFenQi: e.mFenQi
        })
    }, mediForm.ctrls.TNMStagingOvarianCtrl = function () {}, mediForm.ctrls.registerType("TNMStagingOvarian", mediForm.ctrls.TNMStagingOvarianCtrl), mediForm.ctrls.TNMStagingOvarianCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            n = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (n = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='" + n + " form-inline has-group'>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".tFenQi' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>T分期</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: tFenQi'></div>") : (i.push("<select class='form-control' data-bind='value: tFenQi'>"), i.push(" <option value=''>（请选择...）</option>"), i.push(a.render(["T0", "T1a", "T1b", "T1c", "T2", "T2a", "T2b", "T2c", "T3", "T3a", "T3b", "T3c"])), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".nFenQi' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>N分期</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: nFenQi'></div>") : (i.push("<select class='form-control' data-bind='value: nFenQi'>"), i.push(" <option value=''>（请选择...）</option>"), i.push(a.render(["N0", "N1"])), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".mFenQi' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>M分期</div>"), e ? i.push("<div class='form-control' style='width:80px' data-bind='text: mFenQi'></div>") : (i.push("<select class='form-control' data-bind='value: mFenQi'>"), i.push(" <option value=''>（请选择...）</option>"), i.push(a.render(["M0", "M1"])), i.push("</select>")), i.push("    </div>"), i.push("</div>"), i.push("<div class='form-group medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".fenQiJieGuo' style='margin-right:10px'>"), i.push("    <div class='input-group'>"), i.push("        <div class='input-group-addon'>分期结果</div>"), i.push("        <div class='form-control' style='width:100px' data-bind='text: fenQiJieGuo'></div>"), i.push("    </div>"), i.push("</div>"), t.$container.html(i.join("")), t.koValue.fenQiJieGuo = ko.pureComputed(function () {
            var e = this.tFenQi(),
                t = this.nFenQi(),
                i = this.mFenQi();
            if ("" === e || "" === t || "" === i) return "--";
            if ("M0" !== i) return "M1-IV";
            if ("N0" !== t) return "N1-IIIC";
            var a = e;
            switch (a) {
                case "T1":
                    return "I";
                case "T1a":
                    return "IA";
                case "T1b":
                    return "IB";
                case "T1c":
                    return "IC";
                case "T2":
                    return "II";
                case "T2a":
                    return "IIA";
                case "T2b":
                    return "IIB";
                case "T2c":
                    return "IIC";
                case "T3":
                    return "III";
                case "T3a":
                    return "IIIA";
                case "T3b":
                    return "IIIB";
                case "T3c":
                    return "IIIC"
            }
            return "--"
        }, t.koValue)
    }, mediForm.ctrls.TNMStagingOvarianCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.TNMStagingOvarianCtrl.base.setValue.call(this, {
            tFenQi: e.tFenQi,
            nFenQi: e.nFenQi,
            mFenQi: e.mFenQi
        })
    }, mediForm.ctrls.WritingBoardCtrl = function () {}, mediForm.ctrls.registerType("WritingBoard", mediForm.ctrls.WritingBoardCtrl), mediForm.ctrls.WritingBoardCtrl.prototype.jqs = null, mediForm.ctrls.WritingBoardCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = {},
            a = [];
        this.readonly = e;
        var n = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (n = "field-inline-control", a.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), a.push("<div class='" + n + "' style='position:relative'>"), a.push("     <div class='canvas' style='border:1px solid #999;'>"), a.push("         <canvas></canvas> "), a.push("     </div>"), a.push("     <div class='toolbox text-center' style='display:none;'>"), a.push("          <div class='current'></div>"), a.push("          <button type='button' class='btn btn-default  action-brush first' style='color: #000;' data-color='#000' data-width='2'>"), a.push("              <span class='fa fa-pencil'></span>"), a.push("          </button>"), a.push("          <button type='button' class='btn btn-default  action-brush' style='color: #f00;' data-color='#f00' data-width='2'>"), a.push("              <span class='fa fa-pencil'></span>"), a.push("          </button>"), a.push("          <button type='button' class='btn btn-default  action-brush' style='color: #0f0;' data-color='#0f0' data-width='2'>"), a.push("              <span class='fa fa-pencil'></span>"), a.push("          </button>"), a.push("          <button type='button' class='btn btn-default  action-brush last' style='color: #00f;' data-color='#00f' data-width='2'>"), a.push("              <span class='fa fa-pencil'></span>"), a.push("          </button>"), a.push("          <button type='button' class='btn btn-default  action-erase' style='width:38px;' data-color='#fff' data-width='30'>"), a.push("              <span class='fa fa-eraser'></span>"), a.push("          </button>"), a.push("          <button type='button' class='btn btn-default  action-clear'>"), a.push("              <span class='fa fa-remove'></span>"), a.push("          </button>"), a.push("     </div>"), a.push("</div>"), this.$container.addClass("medi-tip medi-compare medi-metadata-only").attr("data-path", t.fieldInstance.key + ".value").html(a.join("")), i.width = parseInt(t.fieldInstance.data.width) || 380, i.height = parseInt(t.fieldInstance.data.height) || 215, e || (t.fieldInstance.data.allowChange || !g_form.result) && (this.$container.find("canvas").jqScribble(), this.$container.find(".toolbox").show(), this.jqs = this.$container.find("canvas").data("jqScribble")), this.$container.find("canvas")[0].width = i.width, this.$container.find("canvas")[0].height = i.height, this.$container.find(".canvas").css({
            width: i.width + 2,
            height: i.height + 2,
            margin: "0 auto"
        }), this.$container.find(".toolbox  .btn-default").css({
            "margin-bottom": "5px"
        }), this.$container.find(".toolbox  .current").css({
            width: "27px",
            height: "27px",
            margin: "10px auto",
            background: "#000"
        }), this.$container.delegate(".toolbox > .action-brush, .toolbox > .action-erase", "click", function (e) {
            e.preventDefault();
            var i = $(this);
            t.$container.find(".toolbox > .current").css("background", i.data("color")), t.jqs && t.jqs.update({
                brushColor: i.data("color"),
                brushSize: i.data("width")
            })
        }).delegate(".toolbox > .action-clear", "click", function (e) {
            e.preventDefault(), t.jqs && t.jqs.clear()
        })
    }, mediForm.ctrls.WritingBoardCtrl.prototype.getDefaultValue = function () {
        return {
            value: ""
        }
    }, mediForm.ctrls.WritingBoardCtrl.prototype.getValue = function () {
        var e = ko.mapping.toJS(this.koValue);
        return this.readonly || (this.fieldInstance.data.allowChange || !g_form.result) && (e.value = this.$container.find("canvas")[0].toDataURL("image/png", 1)), e
    }, mediForm.ctrls.WritingBoardCtrl.prototype.setValue = function (e) {
        var t = this,
            i = this.$container.find("canvas")[0],
            a = i.getContext("2d"),
            n = new Image;
        ko.mapping.fromJS(e, this.koValue()), n.src = e.value, n.onload = function () {
            a.webkitImageSmoothingEnabled = !0, a.imageSmoothingEnabled = !0, a.drawImage(n, 0, 0, i.width, i.height), t.jqs && t.jqs.update({
                brushColor: "#000",
                brushSize: 2
            })
        }
    }, mediForm.ctrls.YesNoCheckBoxListCtrl = function () {}, mediForm.ctrls.registerType("YesNoCheckBoxList", mediForm.ctrls.YesNoCheckBoxListCtrl), mediForm.ctrls.YesNoCheckBoxListCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = this.fieldInstance.config.yes,
            n = this.fieldInstance.config.no,
            s = this.fieldInstance.config.width ? this.fieldInstance.config.width : "100px",
            l = $.templates("<label class='checkbox-inline' style='width:" + s + ";'><input type='checkbox' value='{{attr: #data}}' data-bind='checked: detail' />{{> #data}}</label>"),
            o = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (o = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='medi-tip " + o + "'" + (e ? "" : " style='padding-top:7px'") + " data-path='" + t.fieldInstance.key + ".yesNo'>"), e ? (i.push(" <span class='medi-compare' data-path='" + t.fieldInstance.key + ".yesNo' data-bind='visible: yesNo() === \"" + n + "\"'>" + n + "</span>"), i.push(" <span class='items medi-compare' data-path='" + t.fieldInstance.key + ".detail#' data-bind='visible: yesNo() === \"" + a + "\"'></span>"), i.push("</div>")) : (i.push("<label class='radio-inline medi-compare' style='min-width: 56px' data-path='" + t.fieldInstance.key + ".yesNo'>"), i.push(" <input type='radio' name='" + this.fieldInstance.key + "' value='" + a + "' data-bind='checked: yesNo' />" + a), i.push("</label>"), i.push("<label class='radio-inline medi-compare' style='min-width: 56px;margin-left:0' data-path='" + t.fieldInstance.key + ".yesNo'>"), i.push(" <input type='radio' name='" + this.fieldInstance.key + "' value='" + n + "' data-bind='checked: yesNo' />" + n), i.push("</label>"), i.push("</div>"), i.push("<div class='checkList medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".detail#' style='margin-top:5px' data-bind='visible: yesNo() === \"" + a + "\"'>"), i.push(l.render(this.fieldInstance.config.options)), i.push("</div>")), this.$container.html(i.join("")), this.koValue.yesNo.subscribe(function (e) {
            e === n && t.koValue().detail([])
        })
    }, mediForm.ctrls.YesNoCheckBoxListCtrl.prototype.getDefaultValue = function () {
        return {
            yesNo: this.fieldInstance.config.no,
            detail: []
        }
    }, mediForm.ctrls.YesNoCheckBoxListCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.YesNoCheckBoxListCtrl.base.getValue.call(this),
            t = this.fieldInstance.config.options,
            i = e.detail;
        return e.detail = t.filter(function (e) {
            return i.indexOf(e) > -1
        }), e
    }, mediForm.ctrls.YesNoCheckBoxListCtrl.prototype.setValue = function (e) {
        mediForm.ctrls.YesNoCheckBoxListCtrl.base.setValue.call(this, e), e && e.detail && e.detail.length > 0 && this.$container.find(".items").text(e.detail.join(", "))
    }, mediForm.ctrls.YesNoSimpleObjectCtrl = function () {
        this.dispItems = []
    }, mediForm.ctrls.registerType("YesNoSimpleObject", mediForm.ctrls.YesNoSimpleObjectCtrl), mediForm.ctrls.YesNoSimpleObjectCtrl.prototype.internalRender = function (e) {
        function t(t) {
            var i = e ? "min-width" : "width";
            if (t.options && !t.allowFill && !t.subtype) return "";
            if (t.width) return " style='" + i + ":" + t.width + "'";
            if (t.subtype) return " style='" + i + ":150px'";
            switch (t.type) {
                case "integer":
                case "float":
                    return " style='" + i + ":80px'";
                case "date":
                    return " style='" + i + ":120px'";
                case "textarea":
                case "rich":
                    return " style='" + i + ":400px'";
                default:
                    return " style='" + i + ":100px'"
            }
        }

        function i(e) {
            var i = e.skipInput ? " skip-input" : "";
            if ($.isArray(e.options))
                if (e.allowFill) n.push("<div class='input-group dropdown combo" + i + "'>"), n.push(" <input type='text' class='form-control' " + t(e) + " data-bind='value: detail." + e.key + "' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(l.render(e.options)), n.push("     </ul>"), n.push(" </div>"), n.push("</div>");
                else if (e.subtype) {
                var a = $.map(e.options, function (t) {
                    return {
                        key: "detail." + e.key,
                        option: t
                    }
                });
                n.push("<div class='input-group dropdown checkList" + i + "'>"), n.push(" <input type='text' class='form-control' " + t(e) + " data-bind='value: detail." + e.key + "' readonly='readonly' />"), n.push(" <div class='input-group-btn'>"), n.push("     <button class='btn btn-default dropdown-toggle' type='button' data-toggle='dropdown'>"), n.push("         <span class='caret'></span>"), n.push("     </button>"), n.push("     <ul class='dropdown-menu pull-right' role='menu'>"), n.push(o.render(a)), n.push("     </ul>"), n.push(" </div>"), n.push("</div>")
            } else n.push("<select class='form-control" + i), e.search && n.push(" selectpicker"), n.push("'"), n.push(" data-bind='value: detail." + e.key + "'>"), n.push("<option value=''>（请选择...）</option>"), n.push(s.render(e.options)), n.push("</select>");
            else "rich" === e.type ? n.push("<div class='froala-editor" + i + "' " + t(e) + " data-bind='froala: detail." + e.key + "'></div>") : "textarea" === e.type ? (n.push("<textarea class='form-control auto-sizable" + i + "' rows='1' data-bind='value: detail." + e.key + "' "), n.push(t(e) + "></textarea>")) : (n.push("<input type='text' class='form-control" + i), "date" === e.type && n.push(" calendar"), n.push("' data-bind='value: detail." + e.key + "' "), n.push(mediForm.util.getTextValidateTag(!1, e.type, e.pattern)), n.push(t(e) + " />"))
        }
        var a = this,
            n = [],
            s = $.templates("<option value='{{attr: #data}}'>{{> #data}}</option>"),
            l = $.templates("<li role='presentation'><a role='menuitem' tabindex='-1' href='#'>{{> #data}}</a></li>"),
            o = $.templates("<li role='presentation' data-value='{{attr: option}}' data-bind='mediCheckList: {{:key}}'><a role='menuitem' tabindex='-1' href='#'><span class='fa fa-fw'></span> {{> option}}</a></li>"),
            d = mediForm.util.findKeyInSub(this.fieldInstance.data, "detail"),
            r = this.fieldInstance.config.yes,
            u = this.fieldInstance.config.no;
        this.dispItems = [], $.map(d.sub, function (e) {
            a.dispItems.push(e)
        });
        var p = "field-inline-control-noTitle";
        a.fieldInstance.layout.hideTitle || (p = "field-inline-control", n.push("<div class='field-inline-label'><label class='control-label'>" + a.fieldInstance.name + "</label></div>")), n.push("<div class='medi-tip " + p + "'" + (e ? "" : " style='padding-top:7px'") + " data-path='" + a.fieldInstance.key + ".yesNo'>"), e ? n.push("<span class='medi-compare' data-path='" + a.fieldInstance.key + ".yesNo' data-bind='visible: yesNo() === \"" + u + "\"'>" + u + "</span>") : (n.push("<label class='radio-inline medi-compare' style='min-width: 56px;height:30px' data-path='" + a.fieldInstance.key + ".yesNo'>"), n.push(" <input type='radio' name='" + this.fieldInstance.key + "' value='" + r + "' data-bind='checked: yesNo' />" + r), n.push("</label>"), n.push("<label class='radio-inline medi-compare' style='min-width: 56px;margin-left:0;height:30px' data-path='" + a.fieldInstance.key + ".yesNo'>"), n.push(" <input type='radio' name='" + this.fieldInstance.key + "' value='" + u + "' data-bind='checked: yesNo' />" + u), n.push("</label>")), n.push("<div class='form-inline has-group simple-object' data-bind='visible: yesNo() === \"" + r + "\"'>"), $.map(this.dispItems, function (s) {
            var l = "rich" === s.type ? "html" : "text";
            s.newLine && n.push("<div></div>"), n.push("<div class='form-group medi-tip medi-compare' data-path='" + a.fieldInstance.key + ".detail." + s.key + (s.subtype ? "#" : "") + "' data-subkey='" + s.key + "'>"), n.push("    <div class='input-group'>"), n.push("        <div class='input-group-addon'>" + s.name + "</div>"), e ? n.push("<div class='form-control field-value " + (s.subtype || s.type) + "'" + t(s) + " data-bind='" + l + ": detail." + s.key + "'></div>") : s.readonly ? n.push("<div class='form-control field-value field-readonly " + (s.subtype || s.type) + "'" + t(s) + " data-bind='" + l + ": detail." + s.key + "'></div>") : i(s), n.push("    </div>"), n.push("    <div class='error-msg' data-bind='validationMessage: detail." + s.key + "'></div>"), n.push("</div>")
        }), n.push("</div></div>"), this.$container.html(n.join("")), a.$container.find("input.calendar").datepicker({
            todayBtn: "linked",
            format: "yyyy-mm-dd",
            language: "zh-CN",
            autoclose: !0
        }), a.$container.find("button.dropdown-toggle").dropdown(), a.$container.find(".selectpicker").selectpicker({
            liveSearch: !0,
            noneResultsText: "无相关数据",
            width: "auto",
            size: 10
        }).selectpicker("refresh"), a.$container.delegate("textarea.auto-sizable", "keyup", $.debounce(200, !1, function () {
            mediForm.util.autoSizeTextarea(this, 1, 9)
        })).delegate("div.dropdown", "shown.bs.dropdown", function () {
            $(this).find("ul.dropdown-menu").outerWidth($(this).outerWidth())
        }).delegate(".combo ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), $(this).parents(".dropdown:eq(0)").children("input").val($(this).text()).trigger("change")
        }), a.$container.delegate(".checkList ul.dropdown-menu a", "click", function (e) {
            e.preventDefault(), e.stopPropagation()
        }), this.koValue.yesNo.subscribe(function (e) {
            e === u && $.each(a.dispItems, function (e, t) {
                a.koValue().detail[t.key](t.subtype ? [] : null)
            })
        })
    }, mediForm.ctrls.YesNoSimpleObjectCtrl.prototype.getDefaultValue = function () {
        var e = mediForm.ctrls.YesNoSimpleObjectCtrl.base.getDefaultValue.call(this);
        return e.yesNo = this.fieldInstance.config.no, e
    }, mediForm.ctrls.YesNoSimpleObjectCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.YesNoSimpleObjectCtrl.base.getValue.call(this);
        return e.yesNo === this.fieldInstance.config.yes && $.map(this.dispItems, function (t) {
            t.subtype && !e.detail[t.key] && (e.detail[t.key] = []), t.subtype || "" !== $.trim(e.detail[t.key]) || (e.detail[t.key] = null), "integer" !== t.type && "float" !== t.type || null === e.detail[t.key] || (e.detail[t.key] = parseFloat(e.detail[t.key]))
        }), e
    }, mediForm.ctrls.YesNoSimpleObjectCtrl.prototype.setValue = function (e) {
        var t = this;
        this.correctValue(e), mediForm.ctrls.YesNoSimpleObjectCtrl.base.setValue.call(this, e), this.$container.find("input.calendar").datepicker("update"), t.$container.find(".selectpicker").selectpicker({
            liveSearch: !0,
            noneResultsText: "无相关数据",
            width: "auto",
            size: 10
        }).selectpicker("refresh"), window.setTimeout(function () {
            t.$container.find("textarea.auto-sizable").each(function () {
                mediForm.util.autoSizeTextarea(this, 1, 9)
            })
        }, 0)
    }, mediForm.ctrls.YesNoTextCtrl = function () {}, mediForm.ctrls.registerType("YesNoText", mediForm.ctrls.YesNoTextCtrl), mediForm.ctrls.YesNoTextCtrl.prototype.internalRender = function (e) {
        var t = this,
            i = [],
            a = this.fieldInstance.config.yes,
            n = this.fieldInstance.config.no,
            s = mediForm.util.getTextValidateTag(!1, this.fieldInstance.data.type, this.fieldInstance.config.pattern),
            l = "field-inline-control-noTitle";
        t.fieldInstance.layout.hideTitle || (l = "field-inline-control", i.push("<div class='field-inline-label'><label class='control-label'>" + t.fieldInstance.name + "</label></div>")), i.push("<div class='medi-tip " + l + "'" + (e ? "" : " style='padding-top:7px'") + " data-path='" + t.fieldInstance.key + ".yesNo'>"), e ? (i.push("<span class='medi-compare' data-path='" + t.fieldInstance.key + ".yesNo' data-bind='visible: yesNo() === \"" + n + "\"'>" + n + "</span>"), i.push("<span class='medi-compare' data-path='" + t.fieldInstance.key + ".detail' data-bind='text: detail, visible: yesNo() === \"" + a + "\"'></span>")) : (i.push("<label class='radio-inline medi-compare' style='min-width: 56px' data-path='" + t.fieldInstance.key + ".yesNo'>"), i.push(" <input type='radio' name='" + this.fieldInstance.key + "' value='" + a + "' data-bind='checked: yesNo' />" + a), i.push("</label>"), i.push("<label class='radio-inline medi-compare' style='min-width: 56px;margin-left:0;' data-path='" + t.fieldInstance.key + ".yesNo'>"), i.push(" <input type='radio' name='" + this.fieldInstance.key + "' value='" + n + "' data-bind='checked: yesNo' />" + n), i.push("</label>"), i.push("<div class='medi-tip medi-compare' data-path='" + t.fieldInstance.key + ".detail' style='margin-top:5px' data-bind='visible: yesNo() === \"" + a + "\"'>"), this.fieldInstance.config.multiline ? (i.push("<textarea class='form-control' rows='3' "), i.push(s), i.push("     data-bind='value: detail'></textarea>")) : (i.push("<input type='text' class='form-control' "), i.push(s), i.push("		data-bind='value: detail' />")), i.push("</div>")), i.push("</div>"), this.$container.html(i.join("")), this.koValue.yesNo.subscribe(function (e) {
            e === n && t.koValue().detail(null)
        })
    }, mediForm.ctrls.YesNoTextCtrl.prototype.getDefaultValue = function () {
        return {
            yesNo: this.fieldInstance.config.no,
            detail: null
        }
    }, mediForm.ctrls.YesNoTextCtrl.prototype.getValue = function () {
        var e = mediForm.ctrls.YesNoTextCtrl.base.getValue.call(this);
        return e.yesNo === this.fieldInstance.config.yes && ("" === $.trim(e.detail) && (e.detail = null), null === e.detail || "integer" !== this.fieldInstance.data.type && "float" !== this.fieldInstance.data.type || (e.detail = parseFloat(e.detail))), e
    },
    function () {
        "use strict";

        function e(e, t) {
            return [e.key]
        }

        function t(e) {
            return e.rejectOnError
        }

        function i(e, t) {
            if (!t.validation || !t.rejectOnError) return null;
            var i = mediForm.fldCtrls[e.key],
                a = i.getValue();
            return a && !n(a) ? {
                error: "身份证号码格式有误",
                fieldKey: e.key
            } : null
        }

        function a(e, t, i) {
            function a(e) {
                return 10 > e ? "0" + e.toString() : e.toString()
            }

            function l() {
                return m && t.validation && !n(m) ? i ? {
                    error: "身份证号码格式有误",
                    fieldKey: e.key
                } : (alert("身份证号码格式有误"), void h.$container.find("input:eq(0)").focus()) : void 0
            }
            var o, d, r, u, p, c, h = mediForm.fldCtrls[e.key],
                m = h.getValue();
            if (m) {
                if (18 === m.length) o = parseInt(m.substring(6, 10)), d = parseInt(m.substring(10, 12)), r = parseInt(m.substring(12, 14)), p = parseInt(m.substring(16, 17));
                else {
                    if (15 !== m.length) return l();
                    o = parseInt("19" + m.substring(6, 8)), d = parseInt(m.substring(8, 10)), r = parseInt(m.substring(10, 12)), p = parseInt(m.substring(14, 15))
                }
                return u = !isNaN(o) && !isNaN(d) && !isNaN(r) && o > 0 && d > 0 && 13 > d && r > 0 && 32 > r, t.birthField && mediForm.fldCtrls[t.birthField] && u && mediForm.fldCtrls[t.birthField].setValue(o + "-" + a(d) + "-" + a(r)), c = !isNaN(p), t.genderField && mediForm.fldCtrls[t.genderField] && c && mediForm.fldCtrls[t.genderField].setValue(p % 2 === 0 ? "女" : "男"), t.ageField && mediForm.fldCtrls[t.ageField] && u && mediForm.fldCtrls[t.ageField].setValue(s(o, d, r)), l()
            }
        }

        function n(e) {
            if (!e) return !0;
            if (!l.test(e)) return !1;
            if (15 === e.length) return !0;
            for (var t = 0, i = 0; 17 > i; i++) t += parseInt(e.charAt(i)) * o[i];
            return e.charAt(17).toUpperCase() === d[t % 11]
        }

        function s(e, t, i) {
            var a, n, s, l = new Date,
                o = l.getFullYear(),
                d = l.getMonth() + 1,
                r = l.getDate();
            return o === e ? t > d ? null : d === t && i > r ? null : 0 : (a = o - e, 0 > a ? null : d === t ? (s = r - i, 0 > s ? a - 1 : a) : (n = d - t, 0 > n ? a - 1 : a))
        }
        var l = /^(^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$)|(^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[Xx])$)$/,
            o = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2],
            d = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.certificateId = {
            inCtrlLogic: !1,
            getSubscribeFields: e,
            execute: a,
            needSaveLogic: t,
            getError: i
        }
    }(),
    function () {
        "use strict";

        function e(e, t) {
            var i = [];
            return t.dateFirst && "[NOW]" !== t.dateFirst && i.push(t.dateFirst), t.dateSecond && "[NOW]" !== t.dateSecond && i.push(t.dateSecond), i
        }

        function t(e) {
            return e.rejectOnError
        }

        function i(e, t) {
            if (!t.rejectOnError) return null;
            var i = p(t.dateFirst),
                a = p(t.dateSecond);
            if (!i.isValid || !a.isValid) return null;
            var s = n(i, a, t.mode),
                l = null;
            return d(s, t.validation) ? null : ("[NOW]" !== t.dateFirst ? l = t.dateFirst : "[NOW]" !== t.dateSecond && (l = t.dateSecond), {
                error: t.errorMsg,
                fieldKey: l
            })
        }

        function a(e, t, i) {
            var a = p(t.dateFirst),
                s = p(t.dateSecond);
            if (a.isValid && s.isValid) {
                var l = n(a, s, t.mode),
                    o = "day" === t.mode ? l : n(a, s, "day"),
                    u = mediForm.fldCtrls[e.key],
                    c = null;
                if (d(o, t.validation)) u.setValue(r(l, t.precision, t.convMode));
                else if (u.setValue(null), t.errorMsg) {
                    if (i) return "[NOW]" !== t.dateFirst ? c = t.dateFirst : "[NOW]" !== t.dateSecond && (c = t.dateSecond), {
                        error: t.errorMsg,
                        fieldKey: c
                    };
                    alert(t.errorMsg)
                }
            }
        }

        function n(e, t, i) {
            switch (i) {
                case "year":
                    return o(e, t);
                case "month":
                    return l(e, t);
                default:
                    return s(e, t)
            }
        }

        function s(e, t) {
            return (Date.parse(u(e)) - Date.parse(u(t))) / 864e5
        }

        function l(e, t) {
            return 12 * (e.year - t.year) + (e.month - t.month) + (e.day - t.day) / 30
        }

        function o(e, t) {
            return s(e, t) / 365.2422
        }

        function d(e, t) {
            switch (t) {
                case "gt":
                    return e > 0;
                case "gte":
                    return e >= 0;
                case "lt":
                    return 0 > e;
                case "lte":
                    return 0 >= e;
                default:
                    return !0
            }
        }

        function r(e, t, i) {
            var a = parseInt(t);
            if (isNaN(a)) return e;
            var n = Math.pow(10, a);
            return Math[i](e * n) / n
        }

        function u(e) {
            function t(e) {
                return 10 > e ? "0" + e.toString() : e.toString()
            }
            return e.year + "-" + t(e.month) + "-" + t(e.day)
        }

        function p(e) {
            if (e) {
                if ("[NOW]" === e) {
                    var t = new Date;
                    return {
                        year: t.getFullYear(),
                        month: t.getMonth() + 1,
                        day: t.getDate(),
                        isValid: !0
                    }
                }
                if (mediForm.fldCtrls[e]) {
                    var i = mediForm.fldCtrls[e].getValue();
                    if (!i) return {
                        isValid: !1
                    };
                    var a = i.split("-");
                    if (3 !== a.length) return {
                        isValid: !1
                    };
                    var n = {
                        year: parseInt(a[0]),
                        month: parseInt(a[1]),
                        day: parseInt(a[2])
                    };
                    return n.isValid = !isNaN(n.year) && !isNaN(n.month) && !isNaN(n.day), n
                }
                return {
                    isValid: !1
                }
            }
            return {
                isValid: !1
            }
        }
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.dateCalculate = {
            inCtrlLogic: !1,
            getSubscribeFields: e,
            execute: a,
            needSaveLogic: t,
            getError: i
        }
    }(),
    function () {
        "use strict";

        function getSubscribeFields(e, t) {
            var i = t.formula.match(_re);
            i = i.map(function (e) {
                return e.substr(1, e.length - 2)
            });
            var a = {},
                n = [];
            return i.forEach(function (t) {
                a[t] || t === e.key || (a[t] = !0, n.push(t))
            }), n
        }

        function execute(mainField, logic) {
            var fields = logic.formula.match(_re),
                formula = logic.formula;
            fields.forEach(function (e) {
                var t = getFieldValue(e.substr(1, e.length - 2), logic.sourcePrecision, logic.sourceConvMode);
                formula = formula.replace(e, "(" + t.toString() + ")")
            });
            var result = null;
            try {
                result = eval(formula), result = isFinite(result) ? getPrecision(result, logic.resultPrecision, logic.resultConvMode) : null
            } catch (e) {
                console.log(e), result = null
            }
            mediForm.fldCtrls[mainField.key].setValue(result)
        }

        function getFieldValue(e, t, i) {
            var a = mediForm.fldCtrls[e];
            return a ? getPrecision(parseFloat(a.getValue()) || 0, t, i) : 0
        }

        function getPrecision(e, t, i) {
            var a = parseInt(t);
            if (isNaN(a)) return e;
            var n = Math.pow(10, a);
            return Math[i](e * n) / n
        }
        var _re = /\[[_0-9A-Za-z]+\]/g;
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.numCalculate = {
            inCtrlLogic: !1,
            getSubscribeFields: getSubscribeFields,
            execute: execute
        }
    }(),
    function () {
        "use strict";

        function clearStatus() {
            _logicIdCount = 0, _rowsCount = {}
        }

        function initLogic(e, t) {
            var i = mediForm.fldCtrls[e.key];
            "SimpleObject" === e.ctrl ? t.forEach(function (e) {
                subscribeItem(i.koValue(), e, getWatchSubFields(e))
            }) : t.forEach(function (e) {
                e._internalId = e._internalId || _logicIdCount++, _rowsCount[e._internalId] = i.getValue().length;
                var t = getWatchSubFields(e);
                i.koValue().result().forEach(function (i) {
                    subscribeItem(i, e, t)
                }), i.koValue().result.subscribe(function (i) {
                    for (var a = _rowsCount[e._internalId], n = i.length, s = a; n > s; s++) subscribeItem(i[s], e, t);
                    _rowsCount[e._internalId] = n
                })
            })
        }

        function getWatchSubFields(e) {
            var t = e.formula.match(_re);
            t = t.map(function (e) {
                return e.substr(1, e.length - 2)
            });
            var i = {},
                a = [];
            return t.forEach(function (t) {
                i[t] || t === e.targetField || (i[t] = !0, a.push(t))
            }), a
        }

        function subscribeItem(e, t, i) {
            t.refreshOnOpen && executeItemLogic(e, t), i.forEach(function (i) {
                "function" == typeof e[i] && e[i].subscribe(function () {
                    executeItemLogic(e, t)
                })
            })
        }

        function executeItemLogic(koItem, logic) {
            if ("function" == typeof koItem[logic.targetField]) {
                var fields = logic.formula.match(_re),
                    formula = logic.formula;
                fields.forEach(function (e) {
                    var t = getFieldValue(koItem, e.substr(1, e.length - 2), logic.sourcePrecision, logic.sourceConvMode);
                    formula = formula.replace(e, "(" + t.toString() + ")")
                });
                var result = null;
                try {
                    result = eval(formula), result = isFinite(result) ? getPrecision(result, logic.resultPrecision, logic.resultConvMode) : null
                } catch (e) {
                    console.log(e), result = null
                }
                koItem[logic.targetField](result)
            }
        }

        function getFieldValue(e, t, i, a) {
            return "function" != typeof e[t] ? 0 : getPrecision(parseFloat(e[t]()) || 0, i, a)
        }

        function getPrecision(e, t, i) {
            var a = parseInt(t);
            if (isNaN(a)) return e;
            var n = Math.pow(10, a);
            return Math[i](e * n) / n
        }
        var _logicIdCount = 0,
            _rowsCount = {},
            _re = /\[[_0-9A-Za-z]+\]/g;
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.numCalculateInCtrl = {
            inCtrlLogic: !0,
            clearStatus: clearStatus,
            initLogic: initLogic
        }
    }(),
    function () {
        "use strict";

        function e(e, t) {
            return [e.key]
        }

        function t(e, t) {
            var i = mediForm.fldCtrls[e.key],
                a = mediForm.fldCtrls[t.targetField],
                n = i.getValue() || "",
                s = t.options[n] || [],
                l = 0;
            a && "function" == typeof a.setOptions && (l = a.setOptions(s), t.hideWhenEmpty && (0 === s.length || 0 === l ? a.hide() : a.show()))
        }
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.option = {
            inCtrlLogic: !1,
            getSubscribeFields: e,
            execute: t
        }
    }(),
    function () {
        "use strict";

        function e() {
            n = {}, s = {}
        }

        function t(e, t) {
            var a = e.key;
            t.forEach(function (e) {
                s[a] || (s[a] = {}), s[a][e.sourceField] || (s[a][e.sourceField] = []), s[a][e.sourceField].push(e)
            });
            var l = [];
            $.each(s[a], function (e, t) {
                l.push(e)
            });
            var o = mediForm.fldCtrls[a];
            "SimpleObject" === e.ctrl ? i(o, o.koValue(), l) : (n[a] = o.getValue().length, o.bindRow(), o.koValue().result().forEach(function (e) {
                i(o, e, l)
            }), o.koValue().result.subscribe(function (t) {
                var s = n[a],
                    d = t.length;
                o.bindRow();
                for (var r = s; d > r; r++) i(o, t[r], l);
                n[e.key] = d
            }))
        }

        function i(e, t, i) {
            i.forEach(function (i) {
                "function" == typeof t[i] && (a(e, t, i), t[i].subscribe(function () {
                    a(e, t, i)
                }))
            })
        }

        function a(e, t, i) {
            var a = t[i](),
                n = s[e.fieldInstance.key][i];
            n.forEach(function (i) {
                var n = i.targetField,
                    s = i.options[a] || [],
                    l = 0;
                "function" == typeof t[n] && (l = e.setOptions(n, s, t), i.hideWhenEmpty && (0 === s.length || 0 === l ? e.hideSubItem(n, t) : e.showSubItem(n, t)))
            })
        }
        var n = {},
            s = {};
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.optionInCtrl = {
            inCtrlLogic: !0,
            clearStatus: e,
            initLogic: t
        }
    }(),
    function () {
        "use strict";

        function e() {
            d = {}, r = {}, u = {}, window.mediForm.logicRule.status.lastStatus = d
        }

        function t(e, t) {
            var i = n(e.key, t);
            return i ? [e.key] : []
        }

        function i(e, t) {
            s(e.key)
        }

        function a(e) {
            var t, i = mediForm.fldCtrls[e];
            return i instanceof mediForm.ctrls.CheckBoxListCtrl ? (t = i.getValue(), t && 0 !== t.length || (t = [""])) : t = [i.getValue() || ""], t
        }

        function n(e, t) {
            var i = !r[e];
            i && (r[e] = {});
            var a = r[e];
            return t.targetFields.forEach(function (e) {
                if (!a[e]) {
                    var i = mediForm.fldCtrls[e];
                    a[e] = {}, i && "function" == typeof i.notifyAlways && i.notifyAlways(!0)
                }
                a[e][t.action] = (a[e][t.action] || []).concat(t.fromValues)
            }), t.targetFields.forEach(function (i) {
                u[i] || (u[i] = {}), u[i][t.action] || (u[i][t.action] = {}), u[i][t.action][e] = (u[i][t.action][e] || []).concat(t.fromValues)
            }), i
        }

        function s(e) {
            function t(e) {
                var t, i = ["CheckBoxList", "Pic", "RepeatTable"];
                t = $.inArray(e.fieldInstance.ctrl, i) > -1 ? [] : e.isSimpleValue ? e.getDefaultValue().value : e.getDefaultValue(), e.setValue(t)
            }
            var i = {};
            $.each(r[e], function (e, t) {
                i[e] = l(e)
            }), $.each(i, function (e, i) {
                var a = mediForm.fldCtrls[e];
                if (!a) return !0;
                var n = d[e];
                return n && n.sort().join() === i.sort().join() ? !0 : (d[e] = i, void i.forEach(function (e) {
                    a[e](), mediForm.logicRule.status.ignoreSetToDefault || ("hide" === e || "show" === e && n && n.indexOf("hide") > -1) && setTimeout(function () {
                        t(a)
                    }, 0)
                }))
            })
        }

        function l(e) {
            var t = [],
                i = u[e];
            return p.forEach(function (e) {
                var n = i[e],
                    s = !1;
                n && ($.each(n, function (e, t) {
                    s = s || o(a(e), t)
                }), t.push(s ? e : c[e]))
            }), t
        }

        function o(e, t) {
            var i = !1;
            return $.each(e, function (e, a) {
                return t.indexOf(a) > -1 ? (i = !0, !1) : void 0
            }), i
        }
        var d = {},
            r = {},
            u = {},
            p = ["hide", "show", "disable", "enable"],
            c = {
                hide: "show",
                show: "hide",
                disable: "enable",
                enable: "disable"
            };
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.status = {
            inCtrlLogic: !1,
            lastStatus: d,
            ignoreSetToDefault: !1,
            clearStatus: e,
            getSubscribeFields: t,
            execute: i
        }
    }(),
    function () {
        "use strict";

        function e() {
            r = {}, u = {}, p = {}
        }

        function t(e, t) {
            t.forEach(function (t) {
                i(e.key, t)
            });
            var n = [],
                s = [];
            $.each(u[e.key], function (e, t) {
                n.push(e), $.each(t, function (e, t) {
                    -1 === s.indexOf(e) && s.push(e)
                })
            });
            var l = mediForm.fldCtrls[e.key];
            "SimpleObject" === e.ctrl ? a(l, l.koValue(), n, s) : (r[e.key] = l.getValue().length, l.bindRow(), l.koValue().result().forEach(function (e) {
                a(l, e, n, s)
            }), l.koValue().result.subscribe(function (t) {
                var i = r[e.key],
                    o = t.length;
                l.bindRow();
                for (var d = i; o > d; d++) a(l, t[d], n, s);
                r[e.key] = o
            }))
        }

        function i(e, t) {
            u[e] || (u[e] = {}), u[e][t.sourceField] || (u[e][t.sourceField] = {});
            var i = u[e][t.sourceField];
            t.targetFields.forEach(function (e) {
                i[e] = i[e] || {}, i[e][t.action] = (i[e][t.action] || []).concat(t.fromValues)
            }), p[e] || (p[e] = {}), t.targetFields.forEach(function (i) {
                p[e][i] || (p[e][i] = {}), p[e][i][t.action] || (p[e][i][t.action] = {}), p[e][i][t.action][t.sourceField] = (p[e][i][t.action][t.sourceField] || []).concat(t.fromValues)
            })
        }

        function a(e, t, i, a) {
            a.forEach(function (e) {
                "function" == typeof t[e] && t[e].extend({
                    notify: "always"
                })
            }), i.forEach(function (i) {
                "function" == typeof t[i] && (n(e, t, i), t[i].subscribe(function () {
                    n(e, t, i)
                }))
            })
        }

        function n(e, t, i) {
            l(e, t, i)
        }

        function s(e, t) {
            var i = e[t]();
            return $.isArray(i) ? 0 === i.length && (i = [""]) : i = [i], i
        }

        function l(e, t, i) {
            var a = {},
                n = u[e.fieldInstance.key][i];
            $.each(n, function (i, n) {
                a[i] = o(e.fieldInstance.key, t, i)
            }), $.each(a, function (i, a) {
                a.forEach(function (a) {
                    e[a + "SubItem"](i, t);
                    var n;
                    "hide" === a ? (n = t[i](), $.isArray(n) ? t[i]([]) : t[i](null)) : "show" === a && (n = t[i](), t[i](n))
                })
            })
        }

        function o(e, t, i) {
            var a = [],
                n = p[e][i];
            return c.forEach(function (e) {
                var i = n[e],
                    l = !1;
                i && ($.each(i, function (e, i) {
                    l = l || d(s(t, e), i)
                }), a.push(l ? e : h[e]))
            }), a
        }

        function d(e, t) {
            var i = !1;
            return $.each(e, function (e, a) {
                return t.indexOf(a) > -1 ? (i = !0, !1) : void 0
            }), i
        }
        var r = {},
            u = {},
            p = {},
            c = ["hide", "show", "disable", "enable"],
            h = {
                hide: "show",
                show: "hide",
                disable: "enable",
                enable: "disable"
            };
        window.mediForm = window.mediForm || {}, window.mediForm.logicRule = window.mediForm.logicRule || {}, window.mediForm.logicRule.statusInCtrl = {
            inCtrlLogic: !0,
            clearStatus: e,
            initLogic: t
        }
    }();